DATE
Creates a date from the specified values.
Syntax
=DATE(year)
=DATE(year, month)
=DATE(year, month, day)
=DATE(year, month, day, hours)
=DATE(year, month, day, hours, minutes)
=DATE(year, month, day, hours, minutes, seconds)
=DATE(year, month, day, hours, minutes, seconds, milliseconds)
=DATE(year, month, day, hours, minutes, seconds, milliseconds, offset)
Arguments
Argument | Type | Description |
---|---|---|
year | Number | The year for the new date |
month | Number | (Optional) The month for the new date, defaults to 1 (January) |
day | Number | (Optional) The day for the new date, defaults to 1 |
hours | Number | (Optional) The hours for the new date, defaults to 0 (midnight) |
minutes | Number | (Optional) The minutes for the new date, defaults to 0 |
seconds | Number | (Optional) The seconds for the new date, defaults to 0 |
milliseconds | Number | (Optional) The milliseconds for the new date, defaults to 0 |
offset | Number | (Optional) The timezone offset for the new date, in minutes, defaults to the browser's current timezone offset |
Examples
In the following examples, the current browser has a timezone offset of -7 hours. For more information about offsets see UTC Offset.
=DATE(2020)
→2020-01-01 00:00:00.000
Create a date with the year 2020, and defaults for all other values with the current browser timezone
=DATE(2020, 2)
→2020-02-01 00:00:00.000
Create a date with the year 2020, the month 2, and defaults for all other values with the current browser timezone
=DATE(2020, 2, 3)
→2020-02-03 00:00:00.000
Create a date with the year 2020, the month 2, the day 3, and defaults for all other values with the current browser timezone
=DATE(2020, 2, 3, 4)
→2020-02-03 04:00:00.000
Create a date with the year 2020, the month 2, the day 3, the hours 4, and defaults for all other values with the current browser timezone
=DATE(2020, 2, 3, 4, 5)
→2020-02-03 04:05:00.000
Create a date with the year 2020, the month 2, the day 3, the hours 4, the minutes 5, and defaults for all other values with the current browser timezone
=DATE(2020, 2, 3, 4, 5, 6)
→2020-02-03 04:05:06.000
Create a date with the year 2020, the month 2, the day 3, the hours 4, the minutes 5, the seconds 6, and defaults for all other values with the current browser timezone
=DATE(2020, 2, 3, 4, 5, 6, 7)
→2020-02-03 04:05:06.007
Create a date with the year 2020, the month 2, the day 3, the hours 4, the minutes 5, the seconds 6, the milliseconds 7, with the current browser timezone
=DATE(2020, 2, 3, 4, 5, 6, 7, -720)
→2020-02-03 09:05:06.007
Create a date with the year 2020, the month 2, the day 3, the hours 4, the minutes 5, the seconds 6, the milliseconds 7, with the timezone offset of -720 (a -12 hours offset)
Updated 10 months ago