Skip to content

Instantly share code, notes, and snippets.

@AlexDemian
Last active October 22, 2018 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexDemian/da8f7bb8b765a140f489b3664b5f6a71 to your computer and use it in GitHub Desktop.
Save AlexDemian/da8f7bb8b765a140f489b3664b5f6a71 to your computer and use it in GitHub Desktop.
Some postgres funcs and tricks
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