Input (SQL) | Output |
---|---|
SELECT CURRENT_DATE; | 2023-04-02 |
SELECT CURRENT_TIME; | 19:39:54.319168 |
SELECT CURRENT_TIMESTAMP; | 2023-04-02 19:40:08.918141+00 |
SELECT NOW(); | 2023-04-02 19:40:08.918141+00 |
SELECT DATE_TRUNC('year', '2022-03-15'::DATE); | 2022-01-01 00:00:00 |
SELECT DATE_TRUNC('month', '2022-03-15'::DATE); | 2022-03-01 00:00:00 |
SELECT DATE_TRUNC('day', '2022-03-15'::DATE); | 2022-03-15 00:00:00 |
SELECT DATE_TRUNC('hour', '2022-03-15 12:30:45'::TIMESTAMP); | 2022-03-15 12:00:00 |
SELECT DATE_TRUNC('minute', '2022-03-15 12:30:45'::TIMESTAMP); | 2022-03-15 12:30:00 |
SELECT DATE_TRUNC('second', '2022-03-15 12:30:45'::TIMESTAMP); | 2022-03-15 12:30:45 |
SELECT EXTRACT(YEAR FROM '2022-03-15'::DATE); | 2022 |
SELECT EXTRACT(MONTH FROM '2022-03-15'::DATE); | 3 |
SELECT EXTRACT(DAY FROM '2022-03-15'::DATE); | 15 |
SELECT EXTRACT(HOUR FROM '2022-03-15 12:30:45'::TIMESTAMP); | 12 |
SELECT EXTRACT(MINUTE FROM '2022-03-15 12:30:45'::TIMESTAMP); | 30 |
SELECT EXTRACT(SECOND FROM '2022-03-15 12:30:45'::TIMESTAMP); | 45 |
SELECT DATE_PART('day', NOW()); | 2 |
SELECT DATE_PART('month', NOW()); | 4 |
SELECT DATE_PART('year', NOW()); | 2023 |
SELECT DATE_PART('hour', NOW()); | 19 |
SELECT DATE_PART('minute', NOW()); | 40 |
SELECT DATE_PART('second', NOW()); | 8.918141 |
Note that the output values may differ depending on the current date and time when the SQL queries are executed.