Type: Function
Function: DAY
Syntax: DAY([datetime])
Description: This function has two different modes of operation, based on whether an argument is provided or not. With no arguments, it returns the duration of a day in seconds (86400
). With a datetime argument, it returns the day of the month portion (between 1 and 31) for the provided datetime.
Sample usage:
DAY()
is equal to86400
DAY(created_at)
returns the day of the month (between 1 and 31) for thecreated_at
field valueDAY(DATE(2023, 08, 27))
=>27
AVG(closed_at-created_at)/DAY()
returns the time elapsed in days between the creation and closing of a record. Note that the difference between two dates (closed_at-created_at
) is always returned in seconds.created_at + 10*DAY()
returns thecreated_at
field valueplus 10 days.