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

More SQL tasks

Back to the full SQL cheat sheet