RE: to_char(now(), 'YYYY') and time zones

From: Michael Ansley <Michael(dot)Ansley(at)intec-telecom-systems(dot)com>
To: "'simonbc(at)mail1(dot)stofanet(dot)dk'" <simonbc(at)mail1(dot)stofanet(dot)dk>, pgsql-general(at)postgresql(dot)org
Subject: RE: to_char(now(), 'YYYY') and time zones
Date: 2001-04-12 14:27:38
Message-ID: 7F124BC48D56D411812500D0B747251480F523@fileserver002.intecsystems.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

dev=# select to_char((now() at time zone 'utc')::date, 'YYYY');
to_char
---------
2001
(1 row)

>> -----Original Message-----
>> From: Simon Bæk Carstensen [mailto:simonbc(at)email(dot)com]
>> Sent: 12 April 2001 12:40
>> To: pgsql-general(at)postgresql(dot)org
>> Subject: [GENERAL] to_char(now(), 'YYYY') and time zones
>>
>>
>> I'm trying to pull the current year with the following query:
>>
>> select to_char(now(), 'YYYY');
>>
>> This is fine. Now, I would like to select this date in different time
>> zones.
>>
>> Normally I just do:
>>
>> select now() at time zone 'utc';
>>
>> I guess I need a combination of the 2 queries above - one
>> that asks for
>> ONLY the year in a certain time zone (fx UTC or CET).
>>
>> I guess I should do some sort of subselect like:
>>
>> select to_char(utc, 'YYYYY') from (select now() as utc at time zone
>> 'utc')
>>
>> But that jsut gives me an error.
>>
>> Does anyone know how to do this?
>>
>>
>> -- Simon Carstensen
>>
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 2: you can get off all lists at once with the unregister command
>> (send "unregister YourEmailAddressHere" to
>> majordomo(at)postgresql(dot)org)
>>

_________________________________________________________________________
This e-mail and any attachments are confidential and may also be privileged and/or copyright
material of Intec Telecom Systems PLC (or its affiliated companies). If you are not an
intended or authorised recipient of this e-mail or have received it in error, please delete
it immediately and notify the sender by e-mail. In such a case, reading, reproducing,
printing or further dissemination of this e-mail is strictly prohibited and may be unlawful.
Intec Telecom Systems PLC. does not represent or warrant that an attachment hereto is free
from computer viruses or other defects. The opinions expressed in this e-mail and any
attachments may be those of the author and are not necessarily those of Intec Telecom
Systems PLC.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
__________________________________________________________________________

Browse pgsql-general by date

  From Date Subject
Next Message Louis-David Mitterrand 2001-04-12 16:37:07 no OID field in OLD or NEW records inside trigger functions?
Previous Message Alessio Bragadini 2001-04-12 14:03:42 Re: to_char(now(), 'YYYY') and time zones