SQL NOW / CURRENT_TIMESTAMP: Get Current Date and Time (All Databases)
Get the current date and time in SQL. Covers NOW(), CURRENT_TIMESTAMP, GETDATE(), SYSDATE across MySQL, PostgreSQL, SQL Server, Oracle.
Overview
Getting the current date and time is one of the most common operations in SQL. Every database supports it, but the function names differ.
MySQL
SELECT NOW(); -- '2026-03-12 14:30:00'
SELECT CURRENT_TIMESTAMP; -- '2026-03-12 14:30:00'
SELECT CURRENT_DATE; -- '2026-03-12'
SELECT CURRENT_TIME; -- '14:30:00'
SELECT CURDATE(); -- '2026-03-12'
SELECT CURTIME(); -- '14:30:00'
-- Use in queries:
SELECT * FROM orders WHERE created_at >= CURDATE();
INSERT INTO logs (message, created_at) VALUES ('event', NOW());
PostgreSQL
SELECT NOW(); -- '2026-03-12 14:30:00+00'
SELECT CURRENT_TIMESTAMP; -- '2026-03-12 14:30:00+00' (with TZ)
SELECT CURRENT_DATE; -- '2026-03-12'
SELECT CURRENT_TIME; -- '14:30:00+00'
SELECT LOCALTIMESTAMP; -- without timezone
-- clock_timestamp() changes within a transaction:
SELECT clock_timestamp(); -- actual wall clock time
-- NOW() is fixed within a transaction
SQL Server
SELECT GETDATE(); -- '2026-03-12 14:30:00.000'
SELECT CURRENT_TIMESTAMP; -- same as GETDATE()
SELECT SYSDATETIME(); -- higher precision
SELECT GETUTCDATE(); -- UTC time
SELECT CAST(GETDATE() AS DATE); -- date only
SELECT CAST(GETDATE() AS TIME); -- time only
-- Today's records:
SELECT * FROM orders
WHERE CAST(created_at AS DATE) = CAST(GETDATE() AS DATE);
Oracle
SELECT SYSDATE FROM DUAL; -- '12-MAR-26'
SELECT SYSTIMESTAMP FROM DUAL; -- with fractional seconds + TZ
SELECT CURRENT_TIMESTAMP FROM DUAL; -- session timezone
SELECT CURRENT_DATE FROM DUAL; -- session timezone date
-- Format the output:
SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') FROM DUAL;
Skip the Syntax Lookup
Instead of memorizing NOW / CURRENT_TIMESTAMP syntax for each database, describe what you need in plain English and let AI2SQL generate the correct query.
No credit card required
Frequently Asked Questions
How do I get the current date in SQL?
MySQL: NOW() or CURDATE(). PostgreSQL: NOW() or CURRENT_DATE. SQL Server: GETDATE(). Oracle: SYSDATE. CURRENT_TIMESTAMP works in all databases.
What is the difference between NOW() and CURRENT_TIMESTAMP?
In most databases they are identical. The key difference: NOW() is a function call, CURRENT_TIMESTAMP is a SQL standard keyword that doesn't need parentheses.
Can AI2SQL handle date queries?
Yes. Say 'get all orders from today' and AI2SQL generates the correct date comparison for your database.