Date & Time Functions

Last Updated: January 2026


It operates on date and time values and returns a date or time value.


Most Common Date & Time Functions

NOW()

Returns the current date and time.

SELECT NOW();

CURDATE()

Returns the current date.

SELECT CURDATE();

CURTIME()

Returns the current time.

SELECT CURTIME();

YEAR(), MONTH(), DAY()

Extract the year, month, or day from a date.

SELECT YEAR(date_column),
       MONTH(date_column),
       DAY(date_column) FROM table_name;

DATE()

Extract the date from a datetime value.

SELECT DATE(datetime_column) FROM table_name;

DATE_ADD(), DATE_SUB()

Add or subtract a specified number of days from a date.Help to calculate future or past dates.

SELECT DATE_ADD(date_column, INTERVAL 5 DAY),
       DATE_SUB(date_column, INTERVAL 5 DAY) FROM table_name;

DATEDIFF()

Returns the number of days between two dates.

SELECT DATEDIFF(end_date, start_date) FROM table_name;

TIMESTAMP()

Returns the current timestamp.

SELECT TIMESTAMP(NOW());

TIMESTAMPDIFF()

Returns the number of seconds, minutes, hours, days, weeks, months, or years between two timestamps.

SELECT TIMESTAMPDIFF(YEAR, start_date, end_date) FROM table_name;