From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Tomasz Myrta <jasiek(at)klaster(dot)net> |
Cc: | MichaelHoeller(at)t-online(dot)de, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: date calculation |
Date: | 2003-08-22 12:56:50 |
Message-ID: | 6305.1061557010@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Tomasz Myrta <jasiek(at)klaster(dot)net> writes:
> cast('1970-1-1' as timestamp)+cast(your_ticks || ' seconds' as interval)
> Does anyone know better way to cast it?
The above will probably give the wrong answer (off by your timezone
offset). The reference point should be zero hour GMT, but the first
cast will give zero hour local time. You should cast the reference
to timestamp with time zone (timestamptz) instead.
Also, I'd suggest using float-times-interval as a simpler and more
efficient way of forming the offset interval. So:
select 'epoch'::timestamp with time zone + your_ticks * '1 second'::interval;
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2003-08-22 13:00:08 | Re: Bug on parameter bigint in PL/PGSQL |
Previous Message | Tom Lane | 2003-08-22 12:50:15 | Re: "SELECT IN" Still Broken in 7.4b |