CURRENT_DATE returns the server’s current date (00:00:00 time) as a DATE value.
CURRENT_DATE is a SQL standard keyword that returns the date of the database server according to its time zone, with the time portion set to midnight. The result type is DATE, not TIMESTAMP.
Run SELECT CURRENT_DATE;
or SELECT CURRENT_DATE AS today;
. PostgreSQL evaluates the keyword once per transaction, so multiple calls in the same query return identical values.
Yes.Aliasing improves readability and lets client code reference the column easily: SELECT CURRENT_DATE AS order_cutoff;
Filter rows created today: SELECT * FROM Orders WHERE order_date = CURRENT_DATE;
. Compare with intervals: WHERE order_date >= CURRENT_DATE - INTERVAL '7 days'
.
Use CURRENT_DATE in INSERT or UPDATE statements: INSERT INTO Customers (name,email,created_at) VALUES ('Ana','ana@shop.com',CURRENT_DATE);
Prefer CURRENT_DATE for pure date logic—billing cycles, daily reports.Use CURRENT_TIMESTAMP
when you need both date and time. Always be mindful of the server’s time zone.
Daily revenue: SELECT SUM(total_amount) FROM Orders WHERE order_date = CURRENT_DATE;
Mistake 1: Selecting CURRENT_TIMESTAMP when only the date is required. Fix: Use CURRENT_DATE to avoid implicit casting. Mistake 2: Comparing a TIMESTAMP column directly to CURRENT_DATE without casting. Fix: Cast explicitly or use the ::date shorthand.
Yes.Changing the session time zone alters the date CURRENT_DATE returns.
No. PostgreSQL evaluates it once at the start of the transaction.
.
Functionally yes. NOW() returns a TIMESTAMP that you can cast to DATE, but CURRENT_DATE is cleaner and avoids extra casts.
Yes. Example: CHECK (ship_date >= CURRENT_DATE)
ensures future shipping dates.
It follows the server’s time zone settings, so any DST shift applied to the server will reflect in CURRENT_DATE after the change.