Creates a DATETIME value from components, combines a DATE and TIME, or converts from a TIMESTAMP.
DATETIMEDiperbarui: 13 Jun 2026DATETIME(year, month, day, hour, minute, second) | DATETIME(date [, time]) | DATETIME(timestamp [, time_zone])Year
Month (1-12)
Day
Hour (0-23)
Minute (0-59)
Second (0-59)
Date component
Time component (defaults to 00:00:00)
Timestamp to convert
Timezone for timestamp conversion
1 SELECT 2 DATETIME(2024, 1, 15, 14, 30, 0) as dt;
Create a DATETIME from individual year, month, day, hour, minute, and second components.
1 SELECT 2 DATETIME(DATE '2024-01-15', TIME '14:30:00') as combined, 3 DATETIME(DATE '2024-01-15') as date_only;
Combine a DATE and TIME value into a single DATETIME.
| combined | date_only |
|---|---|
| 2024-01-15T14:30:00 | 2024-01-15T00:00:00 |
1 SELECT 2 ts, 3 DATETIME(ts) as dt_utc, 4 DATETIME(ts, 'Asia/Jakarta') as dt_jakarta 5 FROM UNNEST([TIMESTAMP '2024-01-15 10:00:00 UTC']) as ts;
Convert a TIMESTAMP to DATETIME with timezone adjustment.
| ts | dt_utc | dt_jakarta |
|---|---|---|
| 2024-01-15 10:00:00 UTC | 2024-01-15T10:00:00 | 2024-01-15T17:00:00 |
Sudah paham DATETIME? Latih langsung di browser
Latihan interaktif, langsung di browser.