Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I want a query using sysdate like:

select up_time from exam where up_time like sysdate

in Oracle.

However, PostgreSQL does not support sysdate. I could not find sysdate in PostgreSQL documentation. What is used in place of sysdate in PostgreSQL? 

1 Answer

0 votes
by (12.7k points)
edited by

SYSDATE is an Oracle only function.

The ANSI standard defines current_date or current_timestamp which is supported by Postgres and documented in the manual here.

(Btw: Oracle supports CURRENT_TIMESTAMP as well)

You should pay attention to the difference between current_timestamp, statement_timestamp() and clock_timestamp() (which is explained in the manual)

This statement:

select up_time from exam where up_time like sysdate

Does not make any sense at all. Neither in Oracle nor in Postgres. If you need to get the rows from "today", you will have to use the following:

select up_time 
from exam 
where up_time = current_date

Note that in the Oracle you would probably need trunc(up_time) = trunc(sysdate) to get rid of the time part which was always included in Oracle.

Interested in SQL ? Check out this SQL Certification by Intellipaat.

Related questions

0 votes
1 answer
asked Dec 16, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
asked Jan 6, 2021 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...