Introduction
DATE_TRUNC helps you round a date or time to a specific part, like the start of the day or month. It makes dates simpler to compare or group.
DATE_TRUNC('part', timestamp)SELECT DATE_TRUNC('day', TIMESTAMP '2024-06-15 14:23:45');
SELECT DATE_TRUNC('month', TIMESTAMP '2024-06-15 14:23:45');
SELECT DATE_TRUNC('hour', TIMESTAMP '2024-06-15 14:23:45');
SELECT DATE_TRUNC('day', TIMESTAMP '2024-06-15 14:23:45') AS day_start, DATE_TRUNC('month', TIMESTAMP '2024-06-15 14:23:45') AS month_start, DATE_TRUNC('hour', TIMESTAMP '2024-06-15 14:23:45') AS hour_start;
DATE_TRUNC('month', timestamp) do?SELECT DATE_TRUNC('day', TIMESTAMP '2024-06-15 18:23:45');SELECT DATE_TRUNC('min', '2024-06-15 12:34:56');DATE_TRUNC. Which query correctly truncates the timestamp to the start of the week?Pass the test and this pattern moves unknown