Last active
October 22, 2018 08:56
-
-
Save AlexDemian/da8f7bb8b765a140f489b3664b5f6a71 to your computer and use it in GitHub Desktop.
Some postgres funcs and tricks
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
postgres=# SELECT now(), current_date, current_time, current_time - '1m'::interval, now() - '1m'::interval; | |
now | date | timetz | ?column? | ?column? | |
-------------------------------+------------+--------------------+--------------------+------------------------------- | |
2018-10-08 13:20:55.115306+00 | 2018-10-08 | 13:20:55.115306+00 | 13:19:55.115306+00 | 2018-10-08 13:19:55.115306+00 | |
postgres=# select extract(dow from current_date); | |
date_part | |
----------- | |
1 | |
postgres=# select to_char(current_date, 'day'); | |
to_char | |
----------- | |
wednesday | |
postgres=# select extract(dow from current_date); | |
date_part | |
----------- | |
2 | |
postgres=# select now() AT TIME ZONE 'Europe/Kiev'; | |
timezone | |
---------------------------- | |
2018-10-09 12:10:24.948787 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment