Re: Date/Time Conversion

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: James G Wilkinson <jgw(at)alpinegeophysics(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Date/Time Conversion
Date: 2005-04-03 03:50:36
Message-ID: 8222.1112500236@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

James G Wilkinson <jgw(at)alpinegeophysics(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message PFC 2005-04-03 08:03:51 Re: Query history file
Previous Message Yasir Malik 2005-04-03 03:49:52 Re: Date/Time Conversion