Forum OpenACS Q&A: Response to to_char(now(), 'YYYY') and time zones

Collapse
Posted by Dan Wickstrom on
pg is implicitly casting the timestamp to a string, so 11 and is the offset for the time portion of the string and 6 is the length. Actually, I made a mistake the offset should have been 12 and the length should have been five. So, if you wanted the year and the month, you would do:

openacs4=# select substr(now() at time zone 'utc',1,4);
 substr
--------
 2001
(1 row)
 
openacs4=# select substr(now() at time zone 'utc',6,2);
 substr
--------
 04
(1 row)