Helper Helper - 1 year ago 71
SQL Question

How to get day or year number from timestamp column in postgres

I have a Timestamp column in a table like this on postgres


2016-10-26 07:33:51.029
2016-11-01 08:39:12.322

I need to get day like

SELECT day number or may be month number
FROM "MyTable";

expected output would be



Answer Source

You can try

SELECT to_char("your column",'DD') as "day" 
FROM "MyTable";

more at []

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download