Sidebar

Can I get the current date from the datebase?

0 votes
5.5K views
asked Jul 19, 2013 by rich-c-2789 (15,250 points)
Can I get the current date from the datebase?  I need it in an SQL query

1 Answer

+1 vote
 
Best answer

For MySql, H2, Oracle, and SQL Server use:

SELECT CURRENT_TIMESTAMP

For MySql use:

SELECT NOW()

SELECT CURDATE()

SELECT CURRENT_DATE()

SELECT CURTIME()

SELECT CURRENT_TIME()

SELECT CURRENT_TIMESTAMP

SELECT CURRENT_TIMESTAMP()

SELECT SYSDATE() 

SELECT UTC_DATE()

SELECT UTC_DATE

SELECT UTC_TIME()

SELECT UTC_TIME

SELECT UTC_TIMESTAMP()

SELECT UTC_TIMESTAMP

For ORACLE use:

SELECT CURRENT_DATE FROM DUAL

SELECT CURRENT_TIMESTAMP FROM DUAL

SELECT SYSDATE FROM DUAL

SELECT SYSTIMESTAMP FORM DUAL

For SQL Server use:

SELECT GETDATE()

SELECT GETUTCDATE()

SELECT CURRENT_TIMESTAMP

SELECT SYSDATETIME()

SELECT SYSUTCDATETIME()

SELECT {fn NOW()}

For H2 use:

SELECT CURRENT_DATE

SELECT CURRENT_TIME

SELECT CURRENT_TIMESTAMP

SELECT NOW()

 

answered Jul 19, 2013 by rich-c-2789 (15,250 points)
selected Jul 19, 2013 by ron-s-6919
...