DATETIME
Creates a datetime value by combining date and time, or from individual year, month, day, hour, and minute components. Use DATETIME when you need precise timestamps for appointments, deadlines, or time-based calculations.
Syntax
From components:
DATETIME(year, month, day, hour, minute)Combine existing date and time:
DATETIME(date, time)year(Number): Four-digit year (e.g., 2024)month(Number): Month from 1-12day(Number): Day of the month (1-31)hour(Number): Hour in 24-hour format (0-23)minute(Number): Minute (0-59)date(Date): Existing date valuetime(Time): Existing time value (from TIMEVALUE or CURRTIME)
Returns
DateTime object representing the specified date and time.
Examples
Schedule exact appointment time
DATETIME(2024, 12, 25, 14, 30)Returns December 25, 2024 at 2:30 PM.
Combine user date and time inputs
DATETIME(APPOINTMENT_DATE, TIMEVALUE(TIME_INPUT))Merges a date field with a time string like "14:30".
Set event start time
EVENT_START = DATETIME(2024, 10, 15, 9, 0)
EVENT_END = ADDHOURS(EVENT_START, 2)Creates a 2-hour event starting at 9:00 AM on October 15, 2024.
Build deadline with specific time
DEADLINE = DATETIME(YEAR(CURRDATE()), MONTH(CURRDATE()), DAY(CURRDATE()), 17, 0)
HOURS_REMAINING = DATEDIFF(CURRDATETIME(), DEADLINE, "hours")Sets today's deadline at 5:00 PM and calculates hours left.
Use the 5-parameter version when building from scratch. Use the 2-parameter version when combining existing date and time values.
Hours use 24-hour format: 14 = 2:00 PM, not 2. To use 12-hour format, convert first or use TIMEVALUE with "2:00 PM".
Common Patterns
Start of business day:
DATETIME(CURRDATE(), TIMEVALUE("09:00"))End of day deadline:
DATETIME(DUE_DATE, TIMEVALUE("23:59"))Meeting in 2 hours:
ADDHOURS(CURRDATETIME(), 2)Midnight tonight:
DATETIME(ADDDAYS(CURRDATE(), 1), TIMEVALUE("00:00"))Common Mistakes
Using 12-hour time: DATETIME(2024, 1, 1, 2, 30) is 2:30 AM, not 2:30 PM. Use 14 for 2:00 PM.
Missing parameters: All 5 components required when using year/month/day syntax.
Wrong parameter order: It's (year, month, day, hour, minute), not (year, month, day, minute, hour).
See Also
DATE · CURRDATETIME · TIMEVALUE · ADDHOURS · ADDMINUTES · DATEDIFF