Date and time functions
Date arithmetic, formatting, parsing, extraction and clock values.
Date arithmetic, formatting, parsing, extraction and clock values.
adddate
| Signature | Purpose | Source definition |
|---|---|---|
mysql.adddate(date, integer) → date | Add a day count or interval to a date. | SQL |
mysql.adddate(date, interval) → date | Add a day count or interval to a date. | SQL |
mysql.adddate(numeric, integer) → timestamp without time zone | Add a day count or interval to a date. | SQL |
mysql.adddate(numeric, interval) → timestamp without time zone | Add a day count or interval to a date. | SQL |
mysql.adddate(text, integer) → timestamp without time zone | Add a day count or interval to a date. | SQL |
mysql.adddate(text, interval) → timestamp without time zone | Add a day count or interval to a date. | SQL |
mysql.adddate(timestamp without time zone, integer) → timestamp without time zone | Add a day count or interval to a date. | SQL |
mysql.adddate(timestamp without time zone, interval) → timestamp without time zone | Add a day count or interval to a date. | SQL |
addtime
| Signature | Purpose | Source definition |
|---|---|---|
mysql.addtime(text, double precision) → text | Add time values. | SQL |
mysql.addtime(text, text) → text | Add time values. | SQL · C |
mysql.addtime(text, time without time zone) → text | Add time values. | SQL |
mysql.addtime(time without time zone, double precision) → time without time zone | Add time values. | SQL |
mysql.addtime(time without time zone, text) → time without time zone | Add time values. | SQL |
mysql.addtime(time without time zone, time without time zone) → time without time zone | Add time values. | SQL |
mysql.addtime(timestamp without time zone, double precision) → timestamp without time zone | Add time values. | SQL |
mysql.addtime(timestamp without time zone, text) → timestamp without time zone | Add time values. | SQL · C |
mysql.addtime(timestamp without time zone, time without time zone) → timestamp without time zone | Add time values. | SQL · C |
convert_tz
| Signature | Purpose | Source definition |
|---|---|---|
mysql.convert_tz(text, text, text) → timestamp without time zone | Convert a temporal value between time zones. | SQL |
mysql.convert_tz(timestamp without time zone, text, text) → timestamp without time zone | Convert a temporal value between time zones. | SQL |
curdate
| Signature | Purpose | Source definition |
|---|---|---|
mysql.curdate() → date | Return the current date. | SQL |
curtime
| Signature | Purpose | Source definition |
|---|---|---|
mysql.curtime() → time without time zone | Return the current time of day. | SQL |
mysql.curtime(prec integer) → time without time zone | Return the current time of day. | SQL |
date
| Signature | Purpose | Source definition |
|---|---|---|
mysql.date(numeric) → date | Extract or parse a date. | SQL |
pg_catalog.date(text) → date | Extract or parse a date. | SQL |
date_add
| Signature | Purpose | Source definition |
|---|---|---|
mysql.date_add(date, interval) → date | Add a day count or interval to a date. | SQL |
mysql.date_add(numeric, interval) → timestamp without time zone | Add a day count or interval to a date. | SQL |
mysql.date_add(text, interval) → timestamp without time zone | Add a day count or interval to a date. | SQL |
mysql.date_add(timestamp without time zone, interval) → timestamp without time zone | Add a day count or interval to a date. | SQL |
date_format
| Signature | Purpose | Source definition |
|---|---|---|
mysql.date_format(text, text) → text | Format a date with MySQL percent directives. | SQL |
mysql.date_format(timestamp with time zone, text) → text | Format a date with MySQL percent directives. | SQL |
date_sub
| Signature | Purpose | Source definition |
|---|---|---|
mysql.date_sub(date, interval) → date | Subtract a day count or interval from a date. | SQL |
mysql.date_sub(numeric, interval) → timestamp without time zone | Subtract a day count or interval from a date. | SQL |
mysql.date_sub(text, interval) → timestamp without time zone | Subtract a day count or interval from a date. | SQL |
mysql.date_sub(timestamp without time zone, interval) → timestamp without time zone | Subtract a day count or interval from a date. | SQL |
datediff
| Signature | Purpose | Source definition |
|---|---|---|
mysql.datediff(date, date) → integer | Return the difference between two dates in days. | SQL |
mysql.datediff(numeric, numeric) → integer | Return the difference between two dates in days. | SQL |
mysql.datediff(numeric, text) → integer | Return the difference between two dates in days. | SQL |
mysql.datediff(text, numeric) → integer | Return the difference between two dates in days. | SQL |
mysql.datediff(text, text) → integer | Return the difference between two dates in days. | SQL |
mysql.datediff(text, timestamp without time zone) → integer | Return the difference between two dates in days. | SQL |
mysql.datediff(timestamp without time zone, text) → integer | Return the difference between two dates in days. | SQL |
mysql.datediff(timestamp without time zone, timestamp without time zone) → integer | Return the difference between two dates in days. | SQL |
day
| Signature | Purpose | Source definition |
|---|---|---|
mysql.day(numeric) → integer | Return the day of the month. | SQL |
mysql.day(text) → integer | Return the day of the month. | SQL |
mysql.day(timestamp without time zone) → integer | Return the day of the month. | SQL |
dayname
| Signature | Purpose | Source definition |
|---|---|---|
mysql.dayname(numeric) → text | Return the weekday name. | SQL |
mysql.dayname(text) → text | Return the weekday name. | SQL |
mysql.dayname(timestamp without time zone) → text | Return the weekday name. | SQL |
dayofmonth
| Signature | Purpose | Source definition |
|---|---|---|
mysql.dayofmonth(numeric) → integer | Return the day of the month. | SQL |
mysql.dayofmonth(text) → integer | Return the day of the month. | SQL |
mysql.dayofmonth(timestamp without time zone) → integer | Return the day of the month. | SQL |
dayofweek
| Signature | Purpose | Source definition |
|---|---|---|
mysql.dayofweek(numeric) → integer | Number weekdays starting with Sunday as 1. | SQL |
mysql.dayofweek(text) → integer | Number weekdays starting with Sunday as 1. | SQL |
mysql.dayofweek(timestamp without time zone) → integer | Number weekdays starting with Sunday as 1. | SQL |
dayofyear
| Signature | Purpose | Source definition |
|---|---|---|
mysql.dayofyear(numeric) → integer | Return the ordinal day of the year. | SQL |
mysql.dayofyear(text) → integer | Return the ordinal day of the year. | SQL |
mysql.dayofyear(timestamp without time zone) → integer | Return the ordinal day of the year. | SQL |
extract
| Signature | Purpose | Source definition |
|---|---|---|
mysql."extract"(text, text) → numeric | Extract the requested date or time field. | SQL |
mysql."extract"(text, time without time zone) → numeric | Extract the requested date or time field. | SQL · C |
mysql."extract"(text, timestamp without time zone) → numeric | Extract the requested date or time field. | SQL · C |
from_days
| Signature | Purpose | Source definition |
|---|---|---|
mysql.from_days(integer) → date | Convert a MySQL day number to a date. | SQL |
from_unixtime
| Signature | Purpose | Source definition |
|---|---|---|
mysql.from_unixtime(double precision) → timestamp without time zone | Convert Unix time to a date/time value or formatted string. | SQL |
mysql.from_unixtime(double precision, text) → text | Convert Unix time to a date/time value or formatted string. | SQL |
hour
| Signature | Purpose | Source definition |
|---|---|---|
mysql.hour(text) → integer | Extract the hour. | SQL |
mysql.hour(time without time zone) → integer | Extract the hour. | SQL |
mysql.hour(timestamp without time zone) → integer | Extract the hour. | SQL |
last_day
| Signature | Purpose | Source definition |
|---|---|---|
mysql.last_day(date) → date | Find the last date of the month. | SQL |
mysql.last_day(numeric) → date | Find the last date of the month. | SQL |
mysql.last_day(text) → date | Find the last date of the month. | SQL |
mysql.last_day(timestamp with time zone) → date | Find the last date of the month. | SQL |
mysql.last_day(timestamp without time zone) → date | Find the last date of the month. | SQL |
makedate
| Signature | Purpose | Source definition |
|---|---|---|
mysql.makedate(integer, integer) → date | Build a date from a year and day of year. | SQL |
maketime
| Signature | Purpose | Source definition |
|---|---|---|
mysql.maketime(integer, integer, numeric) → time without time zone | Build a time from hours, minutes and seconds. | SQL |
microsecond
| Signature | Purpose | Source definition |
|---|---|---|
mysql.microsecond(text) → integer | Extract microseconds. | SQL |
mysql.microsecond(time without time zone) → integer | Extract microseconds. | SQL |
mysql.microsecond(timestamp without time zone) → integer | Extract microseconds. | SQL |
minute
| Signature | Purpose | Source definition |
|---|---|---|
mysql.minute(text) → integer | Extract minutes. | SQL |
mysql.minute(time without time zone) → integer | Extract minutes. | SQL |
mysql.minute(timestamp without time zone) → integer | Extract minutes. | SQL |
month
| Signature | Purpose | Source definition |
|---|---|---|
mysql.month(numeric) → integer | Return the month number. | SQL |
mysql.month(text) → integer | Return the month number. | SQL |
mysql.month(timestamp without time zone) → integer | Return the month number. | SQL |
monthname
| Signature | Purpose | Source definition |
|---|---|---|
mysql.monthname(numeric) → text | Return the month name. | SQL |
mysql.monthname(text) → text | Return the month name. | SQL |
mysql.monthname(timestamp without time zone) → text | Return the month name. | SQL |
now
| Signature | Purpose | Source definition |
|---|---|---|
mysql.now() → timestamp without time zone | Return the transaction’s current timestamp. | SQL |
mysql.now(prec integer) → timestamp without time zone | Return the transaction’s current timestamp. | SQL |
period_add
| Signature | Purpose | Source definition |
|---|---|---|
mysql.period_add(integer, integer) → text | Add months to a year-month period. | SQL |
period_diff
| Signature | Purpose | Source definition |
|---|---|---|
mysql.period_diff(integer, integer) → integer | Find the difference between year-month periods in months. | SQL |
quarter
| Signature | Purpose | Source definition |
|---|---|---|
mysql.quarter(date) → integer | Return the quarter of the year. | SQL |
mysql.quarter(numeric) → integer | Return the quarter of the year. | SQL |
mysql.quarter(text) → integer | Return the quarter of the year. | SQL |
mysql.quarter(timestamp without time zone) → integer | Return the quarter of the year. | SQL |
sec_to_time
| Signature | Purpose | Source definition |
|---|---|---|
mysql.sec_to_time(bigint) → time without time zone | Convert seconds to a time value. | SQL |
second
| Signature | Purpose | Source definition |
|---|---|---|
mysql.second(text) → integer | Extract seconds. | SQL |
mysql.second(time without time zone) → integer | Extract seconds. | SQL |
mysql.second(timestamp without time zone) → integer | Extract seconds. | SQL |
str_to_date
| Signature | Purpose | Source definition |
|---|---|---|
mysql.str_to_date(text, text) → timestamp without time zone | Parse a date or time with a MySQL format string. | SQL |
subdate
| Signature | Purpose | Source definition |
|---|---|---|
mysql.subdate(date, integer) → date | Subtract a day count or interval from a date. | SQL |
mysql.subdate(date, interval) → timestamp without time zone | Subtract a day count or interval from a date. | SQL |
mysql.subdate(numeric, integer) → timestamp without time zone | Subtract a day count or interval from a date. | SQL |
mysql.subdate(numeric, interval) → timestamp without time zone | Subtract a day count or interval from a date. | SQL |
mysql.subdate(text, integer) → timestamp without time zone | Subtract a day count or interval from a date. | SQL |
mysql.subdate(text, interval) → timestamp without time zone | Subtract a day count or interval from a date. | SQL |
mysql.subdate(timestamp without time zone, integer) → timestamp without time zone | Subtract a day count or interval from a date. | SQL |
mysql.subdate(timestamp without time zone, interval) → timestamp without time zone | Subtract a day count or interval from a date. | SQL |
subtime
sysdate
| Signature | Purpose | Source definition |
|---|---|---|
mysql.sysdate() → timestamp without time zone | Read the wall clock at execution time. | SQL |
mysql.sysdate(prec integer) → timestamp without time zone | Read the wall clock at execution time. | SQL |
time_format
| Signature | Purpose | Source definition |
|---|---|---|
mysql.time_format(time without time zone, text) → text | Format a time value. | SQL |
time_to_sec
| Signature | Purpose | Source definition |
|---|---|---|
mysql.time_to_sec(text) → bigint | Convert a time value to seconds. | SQL |
mysql.time_to_sec(time without time zone) → bigint | Convert a time value to seconds. | SQL |
mysql.time_to_sec(timestamp without time zone) → bigint | Convert a time value to seconds. | SQL |
timediff
| Signature | Purpose | Source definition |
|---|---|---|
mysql.timediff(text, text) → text | Return the difference between two time values. | SQL · C |
mysql.timediff(time without time zone, time without time zone) → text | Return the difference between two time values. | SQL |
mysql.timediff(timestamp without time zone, timestamp without time zone) → text | Return the difference between two time values. | SQL · C |
timestamp
| Signature | Purpose | Source definition |
|---|---|---|
mysql."timestamp"(text, text) → timestamp without time zone | Build a timestamp from the supplied date/time arguments. | SQL |
timestampadd
| Signature | Purpose | Source definition |
|---|---|---|
mysql.timestampadd(text, integer, timestamp without time zone) → timestamp without time zone | Add a quantity in the specified temporal unit. | SQL |
timestampdiff
| Signature | Purpose | Source definition |
|---|---|---|
mysql.timestampdiff(unit text, ts1 text, ts2 text) → bigint | Measure a timestamp difference in the specified unit. | SQL |
mysql.timestampdiff(unit text, ts1 timestamp without time zone, ts2 timestamp without time zone) → bigint | Measure a timestamp difference in the specified unit. | SQL · C |
to_days
| Signature | Purpose | Source definition |
|---|---|---|
mysql.to_days(date) → integer | Convert a date to a MySQL day number. | SQL |
mysql.to_days(text) → integer | Convert a date to a MySQL day number. | SQL |
mysql.to_days(timestamp without time zone) → integer | Convert a date to a MySQL day number. | SQL |
unix_timestamp
| Signature | Purpose | Source definition |
|---|---|---|
mysql.unix_timestamp() → bigint | Return seconds since the Unix epoch. | SQL |
mysql.unix_timestamp(numeric) → numeric | Return seconds since the Unix epoch. | SQL |
mysql.unix_timestamp(text) → numeric | Return seconds since the Unix epoch. | SQL |
mysql.unix_timestamp(timestamp without time zone) → numeric | Return seconds since the Unix epoch. | SQL |
utc_date
| Signature | Purpose | Source definition |
|---|---|---|
mysql.utc_date() → date | Return the current date in UTC. | SQL |
utc_time
| Signature | Purpose | Source definition |
|---|---|---|
mysql.utc_time() → time without time zone | Return the current time of day in UTC. | SQL |
mysql.utc_time(prec integer) → time without time zone | Return the current time of day in UTC. | SQL |
utc_timestamp
| Signature | Purpose | Source definition |
|---|---|---|
mysql.utc_timestamp() → timestamp without time zone | Return the current UTC timestamp. | SQL |
mysql.utc_timestamp(prec integer) → timestamp without time zone | Return the current UTC timestamp. | SQL |
week
| Signature | Purpose | Source definition |
|---|---|---|
mysql.week(numeric) → integer | Return the week number under the selected week mode. | SQL |
mysql.week(numeric, integer) → integer | Return the week number under the selected week mode. | SQL |
mysql.week(text) → integer | Return the week number under the selected week mode. | SQL |
mysql.week(text, integer) → integer | Return the week number under the selected week mode. | SQL |
mysql.week(timestamp without time zone) → integer | Return the week number under the selected week mode. | SQL |
mysql.week(timestamp without time zone, integer) → integer | Return the week number under the selected week mode. | SQL |
weekday
| Signature | Purpose | Source definition |
|---|---|---|
mysql.weekday(numeric) → integer | Number weekdays starting with Monday as 0. | SQL |
mysql.weekday(text) → integer | Number weekdays starting with Monday as 0. | SQL |
mysql.weekday(timestamp without time zone) → integer | Number weekdays starting with Monday as 0. | SQL |
weekofyear
| Signature | Purpose | Source definition |
|---|---|---|
mysql.weekofyear(numeric) → integer | Return the week of the year. | SQL |
mysql.weekofyear(text) → integer | Return the week of the year. | SQL |
mysql.weekofyear(timestamp without time zone) → integer | Return the week of the year. | SQL |
year
| Signature | Purpose | Source definition |
|---|---|---|
mysql.year(date) → integer | Extract the year. | SQL |
mysql.year(numeric) → integer | Extract the year. | SQL |
mysql.year(text) → integer | Extract the year. | SQL |
mysql.year(timestamp without time zone) → integer | Extract the year. | SQL |
yearweek
| Signature | Purpose | Source definition |
|---|---|---|
mysql.yearweek(numeric) → integer | Return the week and its associated year. | SQL |
mysql.yearweek(qdate numeric, mode integer) → integer | Return the week and its associated year. | SQL |
mysql.yearweek(qdate text, mode integer) → integer | Return the week and its associated year. | SQL |
mysql.yearweek(qdate timestamp without time zone, mode integer) → integer | Return the week and its associated year. | SQL |
mysql.yearweek(text) → integer | Return the week and its associated year. | SQL |
mysql.yearweek(timestamp without time zone) → integer | Return the week and its associated year. | SQL |