# Date & Time Functions

- [Date and Time Units](/docs/server/reference/sql-functions/date-time-functions/date-and-time-units.md): Reference keywords for date arithmetic. These units, such as DAY, HOUR, and MINUTE, specify the interval type used in functions like DATE\_ADD and EXTRACT.
- [ADD\_MONTHS](/docs/server/reference/sql-functions/date-time-functions/add_months.md): Add a specific number of months to a date. This Oracle-compatible function simplifies date calculations involving monthly intervals.
- [ADDDATE](/docs/server/reference/sql-functions/date-time-functions/adddate.md): Add a time interval to a date. This function performs date arithmetic, adding a specified value like days or hours to a starting date.
- [ADDTIME](/docs/server/reference/sql-functions/date-time-functions/addtime.md): Add a time value to a date or time expression. This function sums two time arguments, returning a new time or datetime result.
- [CONVERT\_TZ](/docs/server/reference/sql-functions/date-time-functions/convert_tz.md): Convert a datetime value between time zones. This function shifts a timestamp from a source time zone to a target time zone.
- [CURDATE](/docs/server/reference/sql-functions/date-time-functions/curdate.md): Return the current date. This function outputs today's date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on the context.
- [CURRENT\_DATE](/docs/server/reference/sql-functions/date-time-functions/current_date.md): Synonym for CURDATE(). Returns the current date as a value in 'YYYY-MM-DD' or YYYYMMDD format.
- [CURRENT\_TIME](/docs/server/reference/sql-functions/date-time-functions/current_time.md): Synonym for CURTIME(). Returns the current time as a value in 'HH:MM:SS' or HHMMSS format.
- [CURRENT\_TIMESTAMP](/docs/server/reference/sql-functions/date-time-functions/current_timestamp.md): Synonym for NOW(). Returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format.
- [CURTIME](/docs/server/reference/sql-functions/date-time-functions/curtime.md): Return the current time. This function outputs the current time of day as a value in 'HH:MM:SS' or HHMMSS format.
- [DATE FUNCTION](/docs/server/reference/sql-functions/date-time-functions/date-function.md): Extract the date part from a datetime expression. This function returns the year, month, and day portions, discarding the time component.
- [DATE\_ADD](/docs/server/reference/sql-functions/date-time-functions/date_add.md): Complete DATE\_ADD() reference: DATE\_ADD(date, INTERVAL expr unit) syntax, negative interval support, unit keywords (DAY/MONTH/YEAR), and return types.
- [DATE\_FORMAT](/docs/server/reference/sql-functions/date-time-functions/date_format.md): Complete DATE\_FORMAT reference for MariaDB. Complete function guide with syntax, parameters, return values, and usage examples with comprehensive examples.
- [DATE\_SUB](/docs/server/reference/sql-functions/date-time-functions/date_sub.md): Subtract a time interval from a date. This function calculates a past date by subtracting a specified unit, such as days, from a starting value.
- [DATEDIFF](/docs/server/reference/sql-functions/date-time-functions/datediff.md): Complete DATEDIFF() reference: DATEDIFF(expr1,expr2) syntax, date vs datetime expression handling, time component ignore, and positive/negative results.
- [DAY](/docs/server/reference/sql-functions/date-time-functions/day.md): Synonym for DAYOFMONTH(). Returns the day of the month (1-31) for a given date.
- [DAYNAME](/docs/server/reference/sql-functions/date-time-functions/dayname.md): Return the name of the weekday. This function returns the full name of the day, such as 'Monday' or 'Sunday', for a given date.
- [DAYOFMONTH](/docs/server/reference/sql-functions/date-time-functions/dayofmonth.md): Return the day of the month. This function extracts the day portion of a date, returning a number from 1 to 31.
- [DAYOFWEEK](/docs/server/reference/sql-functions/date-time-functions/dayofweek.md): Return the weekday index. This function returns a number from 1 (Sunday) to 7 (Saturday) representing the day of the week.
- [DAYOFYEAR](/docs/server/reference/sql-functions/date-time-functions/dayofyear.md): Return the day of the year. This function returns a number from 1 to 366 indicating the day's position within the year.
- [EXTRACT](/docs/server/reference/sql-functions/date-time-functions/extract.md): Extract a specific part of a date. This function retrieves components like YEAR, MONTH, DAY, or HOUR from a date or datetime expression.
- [FORMAT\_PICO\_TIME](/docs/server/reference/sql-functions/date-time-functions/format_pico_time.md): Format a time in picoseconds. This function converts a numeric picosecond value into a human-readable string with units like ps, ns, us, ms, s, m, h, or d.
- [FROM\_DAYS](/docs/server/reference/sql-functions/date-time-functions/from_days.md): Convert a day number to a date. This function returns a DATE value corresponding to the number of days since year 0.
- [FROM\_UNIXTIME](/docs/server/reference/sql-functions/date-time-functions/from_unixtime.md): Convert a Unix timestamp to a datetime. This function formats a Unix timestamp as a date string or number in the current time zone.
- [GET\_FORMAT](/docs/server/reference/sql-functions/date-time-functions/get_format.md): Return a format string. This function provides standard format strings for DATE\_FORMAT and STR\_TO\_DATE based on regions like 'USA' or 'EUR'.
- [HOUR](/docs/server/reference/sql-functions/date-time-functions/hour.md): Extract the hour. This function returns the hour portion of a time or datetime value as a number from 0 to 23.
- [LAST\_DAY](/docs/server/reference/sql-functions/date-time-functions/last_day.md): Return the last day of the month. This function calculates the date of the final day for the month containing the given date.
- [LOCALTIME](/docs/server/reference/sql-functions/date-time-functions/localtime.md): Synonym for NOW(). Returns the current date and time in the session time zone.
- [LOCALTIMESTAMP](/docs/server/reference/sql-functions/date-time-functions/localtimestamp.md): Synonym for NOW(). Returns the current date and time in the session time zone as a datetime value.
- [MAKEDATE](/docs/server/reference/sql-functions/date-time-functions/makedate.md): Create a date from a year and day of year. This function constructs a DATE value given a year and the day number within that year.
- [MAKETIME](/docs/server/reference/sql-functions/date-time-functions/maketime.md): Create a time from hour, minute, and second. This function constructs a TIME value from three numeric arguments.
- [MICROSECOND](/docs/server/reference/sql-functions/date-time-functions/microsecond.md): Extract microseconds. This function returns the microsecond part of a time or datetime expression as a number from 0 to 999999.
- [Microseconds in MariaDB](/docs/server/reference/sql-functions/date-time-functions/microseconds-in-mariadb.md): Understand microsecond precision. This concept page explains how MariaDB stores and handles fractional seconds in time data types.
- [MINUTE](/docs/server/reference/sql-functions/date-time-functions/minute.md): Extract the minute. This function returns the minute portion of a time or datetime value as a number from 0 to 59.
- [MONTH](/docs/server/reference/sql-functions/date-time-functions/month.md): Extract the month. This function returns the month portion of a date as a number from 1 (January) to 12 (December).
- [MONTHNAME](/docs/server/reference/sql-functions/date-time-functions/monthname.md): Return the name of the month. This function returns the full name of the month, such as 'January' or 'December', for a given date.
- [MONTHS\_BETWEEN](/docs/server/reference/sql-functions/date-time-functions/months_between.md): Calculate the difference between two months.
- [NOW](/docs/server/reference/sql-functions/date-time-functions/now.md): Complete NOW() function reference: NOW(\[precision]) and CURRENT\_TIMESTAMP synonyms, TIMESTAMP vs DATETIME types, timezone/DST handling, and fractional seconds.
- [PERIOD\_ADD](/docs/server/reference/sql-functions/date-time-functions/period_add.md): Add months to a period. This function adds a specified number of months to a period formatted as YYMM or YYYYMM.
- [PERIOD\_DIFF](/docs/server/reference/sql-functions/date-time-functions/period_diff.md): Calculate the difference between periods. This function returns the number of months between two periods formatted as YYMM or YYYYMM.
- [QUARTER](/docs/server/reference/sql-functions/date-time-functions/quarter.md): Return the quarter of the year. This function returns a number from 1 to 4 indicating the quarter for a given date.
- [SEC\_TO\_TIME](/docs/server/reference/sql-functions/date-time-functions/sec_to_time.md): Convert seconds to time. This function returns a TIME value corresponding to the number of seconds elapsed from the start of the day.
- [SECOND](/docs/server/reference/sql-functions/date-time-functions/second.md): Extract the second. This function returns the second portion of a time or datetime value as a number from 0 to 59.
- [STR\_TO\_DATE](/docs/server/reference/sql-functions/date-time-functions/str_to_date.md): Complete STR\_TO\_DATE() reference: parse strings to DATE/TIME/DATETIME, format specifiers (%Y %m %d %H %i %s), invalid input handling, and SQL\_MODE errors.
- [SUBDATE](/docs/server/reference/sql-functions/date-time-functions/subdate.md): Subtract a time interval from a date. This synonym for DATE\_SUB calculates a past date by subtracting a specified unit from a starting value.
- [SUBTIME](/docs/server/reference/sql-functions/date-time-functions/subtime.md): Subtract a time value. This function subtracts one time or datetime expression from another and returns the result.
- [SYSDATE](/docs/server/reference/sql-functions/date-time-functions/sysdate.md): Return the time of execution. Unlike NOW(), which returns the start time of the statement, SYSDATE() returns the time it executes.
- [TIME](/docs/server/reference/sql-functions/date-time-functions/time-function.md): Extract the time portion. This function returns the time part of a time or datetime expression.
- [TIME\_FORMAT](/docs/server/reference/sql-functions/date-time-functions/time_format.md): Format a time. This function formats a time value according to a format string, similar to DATE\_FORMAT but for time values.
- [TIME\_TO\_SEC](/docs/server/reference/sql-functions/date-time-functions/time_to_sec.md)
- [TIMEDIFF](/docs/server/reference/sql-functions/date-time-functions/timediff.md): Subtract two time values. This function calculates the difference between two time or datetime expressions.
- [TIMESTAMP](/docs/server/reference/sql-functions/date-time-functions/timestamp-function.md): Convert to datetime or add time. With one argument, it returns a datetime; with two, it adds a time expression to a date or datetime.
- [TIMESTAMPADD](/docs/server/reference/sql-functions/date-time-functions/timestampadd.md): Add an interval to a timestamp. This function adds a specified integer number of units (like MONTH or SECOND) to a datetime expression.
- [TIMESTAMPDIFF](/docs/server/reference/sql-functions/date-time-functions/timestampdiff.md): Calculate the difference between timestamps. This function returns the difference between two datetime expressions in the specified unit.
- [TO\_DATE](/docs/server/reference/sql-functions/date-time-functions/to_date.md)
- [TO\_DAYS](/docs/server/reference/sql-functions/date-time-functions/to_days.md): Convert a date to a day number. This function returns the number of days between year 0 and the given date.
- [TO\_SECONDS](/docs/server/reference/sql-functions/date-time-functions/to_seconds.md): Convert a date to seconds. This function returns the number of seconds from year 0 to the given date or datetime.
- [TRUNC](/docs/server/reference/sql-functions/date-time-functions/trunc.md): Truncate a date. In Oracle mode, this function truncates a date value to a specified unit of measure.
- [UNIX\_TIMESTAMP](/docs/server/reference/sql-functions/date-time-functions/unix_timestamp.md): Return a Unix timestamp. This function returns the number of seconds since the Unix Epoch ('1970-01-01 00:00:00' UTC).
- [UTC\_DATE](/docs/server/reference/sql-functions/date-time-functions/utc_date.md): Return the current UTC date. This function returns the current Coordinated Universal Time date in 'YYYY-MM-DD' or YYYYMMDD format.
- [UTC\_TIME](/docs/server/reference/sql-functions/date-time-functions/utc_time.md): Return the current UTC time. This function returns the current Coordinated Universal Time in 'HH:MM:SS' or HHMMSS format.
- [UTC\_TIMESTAMP](/docs/server/reference/sql-functions/date-time-functions/utc_timestamp.md): Return the current UTC timestamp. This function returns the current Coordinated Universal Time date and time.
- [WEEK](/docs/server/reference/sql-functions/date-time-functions/week.md): Return the week number. This function returns the week number for a date, with an optional mode to define the start of the week.
- [WEEKDAY](/docs/server/reference/sql-functions/date-time-functions/weekday.md): Return the weekday index. This function returns the index of the day of the week (0=Monday, 6=Sunday).
- [WEEKOFYEAR](/docs/server/reference/sql-functions/date-time-functions/weekofyear.md): Return the calendar week. This function returns the week number of the date (1-53), equivalent to WEEK(date, 3).
- [YEAR](/docs/server/reference/sql-functions/date-time-functions/year.md): Extract the year. This function returns the year portion of a date as a number from 1000 to 9999.
- [YEARWEEK](/docs/server/reference/sql-functions/date-time-functions/yearweek.md): Return the year and week. This function returns the year and week number for a date, useful for grouping results by week.
