Last active
December 20, 2015 19:08
-
-
Save lxneng/6180578 to your computer and use it in GitHub Desktop.
Time in Postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lxneng=# SELECT 'YESTERDAY'::date, 'TODAY'::date, 'TOMORROW'::date; | |
date | date | date | |
------------+------------+------------ | |
2013-08-07 | 2013-08-08 | 2013-08-09 | |
(1 row) | |
lxneng=# select now(); | |
now | |
------------------------------- | |
2013-08-08 09:09:32.687512+08 | |
(1 row) | |
lxneng=# select now() + '1 days'::interval; | |
?column? | |
------------------------------- | |
2013-08-09 09:09:38.610495+08 | |
(1 row) | |
lxneng=# SELECT * FROM generate_series('2012-02-26'::date, '2012-03-02'::date, '1 day'::interval); | |
generate_series | |
------------------------ | |
2012-02-26 00:00:00+08 | |
2012-02-27 00:00:00+08 | |
2012-02-28 00:00:00+08 | |
2012-02-29 00:00:00+08 | |
2012-03-01 00:00:00+08 | |
2012-03-02 00:00:00+08 | |
(6 rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment