Skip to content

Date and Time Functions

NameDescription
DATE(year, month, day)Convert a provided year, month, and day into a date.
DATEDIF(start_date, end_date, unit)Convert a provided year, month, and day into a date. Unit must be "Y", "M", or "D".
DAY(date)Day of month for the given date.
EDATE(start_date, months)Returns the date that is a specific number of months before or after given date.
HOUR(timestamp)Hour of the given timestamp.
MINUTE(timestamp)Minute of the given timestamp.
MONTH(date)Month of year for the given date.
SECOND(timestamp)Second of the given timestamp.
TIMESTAMP_DIFF( start_timestamp, end_timestamp, unit)Timestamp difference. Unit must be "day", "hour", "minute", or "second".
TIMESTAMP_FROM_TEXT( text_representation)Converts a text representation in the form YYYY-MM-DD HH:MM:SS.[zzz]+-TT[:tt] to a timestamp. +-TT[:tt] is the offset from UTC and is required.
TIMESTAMP_FROM_MILLIS( milliseconds)Converts the number of milliseconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP.
YEAR(date)Year for the given date.

Details

DATE(year, month, day)

Convert a provided year, month, and day into a date.


DATEDIF(start_date, end_date, unit)

Convert a provided year, month, and day into a date. Unit must be "Y", "M", or "D".


DAY(date)

Day of month for the given date.


EDATE(start_date, months)

Returns the date that is a specific number of months before or after given date.


HOUR(timestamp)

Hour of the given timestamp.


MINUTE(timestamp)

Minute of the given timestamp.


MONTH(date)

Month of year for the given date.


SECOND(timestamp)

Second of the given timestamp.


TIMESTAMP_DIFF(start_timestamp, end_timestamp, unit)

Timestamp difference. Unit must be "day", "hour", "minute", or "second".


TIMESTAMP_FROM_TEXT(text_representation)

Converts a text representation in the form YYYY-MM-DD HH:MM:SS.[zzz]+-TT[:tt] to a timestamp. +-TT[:tt] is the offset from UTC and is required.


TIMESTAMP_FROM_MILLIS(milliseconds)

Converts the number of milliseconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP.


YEAR(date)

Year for the given date.