Re: Date/Time Conversion - Mailing list pgsql-sql

From Tom Lane
Subject Re: Date/Time Conversion
Date
Msg-id 8222.1112500236@sss.pgh.pa.us
Whole thread Raw
In response to Date/Time Conversion  (James G Wilkinson <jgw@alpinegeophysics.com>)
Responses Re: Date/Time Conversion  (Yasir Malik <ymalik@cs.stevens.edu>)
List pgsql-sql
James G Wilkinson <jgw@alpinegeophysics.com> writes:
> beta_jgw=# update scenario1.time_test set local_day = extract(day from 
> to_timestamp(to_char(gmt_date,'YYYY-MM-DD')||' 
> '||to_char(gmt_hour,'99')||':00:00-00','YYYY-MM-DD HH24:MI:SS') at time 
> zone 'EST');

That seems like a mighty ugly way to do it; have you considered some
kind of timestamp arithmetic instead?  But anyway, I suspect your
problem is you need a few 'FM' format specs to keep the to_char
functions from introducing unwanted spaces.  Look at the intermediate
results of your expressions.
        regards, tom lane


pgsql-sql by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Query history file
Next
From: PFC
Date:
Subject: Re: Query history file