Date & Numeric Functions in SQL
From the SQL cheat sheet ยท Built-in Functions ยท verified Jul 2026
Date & Numeric Functions
Work with dates, times, and numbers.
sql
-- Current date/time
SELECT NOW(); -- Current timestamp
SELECT CURRENT_DATE; -- Current date
SELECT CURRENT_TIMESTAMP; -- ANSI standard
-- Extract parts
SELECT EXTRACT(YEAR FROM created_at) FROM orders;
SELECT EXTRACT(MONTH FROM created_at) FROM orders;
-- Date arithmetic
SELECT created_at + INTERVAL '30 days' FROM orders;๐ก Date functions vary the most across databases โ ANSI EXTRACT works on most
โก DATE_TRUNC is incredibly useful for grouping by month/week/year in reports
๐ ROUND(value, 2) rounds to 2 decimal places โ essential for financial calculations
๐ข Use CURRENT_DATE and CURRENT_TIMESTAMP for portable ANSI-standard date/time
datesnumericfunctionsextract