pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedExtracting date from epoche
4+ messages / 3 participants
[nested] [flat]
* Extracting date from epoche
@ 2001-06-19 15:46 Najm Hashmi <najm@flipr.com>
2001-06-21 09:11 ` Re: Extracting date from epoche Richard Huxton <dev@archonet.com>
0 siblings, 1 reply; 4+ messages in thread
From: Najm Hashmi @ 2001-06-19 15:46 UTC (permalink / raw)
To: pgsql-sql
Hi I have some data that is supose to be a date but in ecpoche
format. How can I reonvert it to data format.
Thanks in advance for help.
Regards,
--
Najm Hashmi
Tel:514-271-9791
www.mondo-live.com
www.flipr.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Extracting date from epoche
2001-06-19 15:46 Extracting date from epoche Najm Hashmi <najm@flipr.com>
@ 2001-06-21 09:11 ` Richard Huxton <dev@archonet.com>
2001-06-21 14:05 ` Re: Extracting date from epoche Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Richard Huxton @ 2001-06-21 09:11 UTC (permalink / raw)
To: pgsql-sql; Najm Hashmi <najm@flipr.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>
----- Original Message -----
From: "Najm Hashmi" <najm@flipr.com>
To: "pgsql" <pgsql-sql@postgresql.org>
Sent: Tuesday, June 19, 2001 4:46 PM
Subject: [SQL] Extracting date from epoche
> Hi I have some data that is supose to be a date but in ecpoche
> format. How can I reonvert it to data format.
> Thanks in advance for help.
> Regards,
Something like:
select '1970-01-01 00:00:00+00'::timestamp
+ (3600::text || ' seconds')::interval;
should work (3600 is your offset, the 1970 assumes std unix epoch start).
Keep an eye on timezone issues.
Example:
richardh=> select 'epoch'::date + (3600::text || ' seconds')::interval;
?column?
------------------------
1970-01-01 01:00:00+01
(1 row)
richardh=> select '1970-01-01 00:00:00+00'::timestamp + (3600::text || '
seconds')::interval;
?column?
------------------------
1970-01-01 02:00:00+01
(1 row)
The difference is because I am currently in timezone +01 and 'epoch' seems
to assume my timezone. In the second example I explicitly set the timezone.
Tom - I thought 'epoch'::timestamp should work too - good reason, or just
One Of Those Things (tm)?
- Richard Huxton
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Extracting date from epoche
2001-06-19 15:46 Extracting date from epoche Najm Hashmi <najm@flipr.com>
2001-06-21 09:11 ` Re: Extracting date from epoche Richard Huxton <dev@archonet.com>
@ 2001-06-21 14:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-06-21 17:47 ` Re: Extracting date from epoche Richard Huxton <dev@archonet.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2001-06-21 14:05 UTC (permalink / raw)
To: Richard Huxton <dev@archonet.com>; +Cc: pgsql-sql; Najm Hashmi <najm@flipr.com>
"Richard Huxton" <dev@archonet.com> writes:
> Tom - I thought 'epoch'::timestamp should work too - good reason, or just
> One Of Those Things (tm)?
It works --- it's a symbolic value, though.
regression=# select 'epoch'::timestamp;
?column?
----------
epoch
(1 row)
regression=# select 'epoch'::timestamp + ('1 day'::interval);
?column?
------------------------
1970-01-01 19:00:00-05
(1 row)
Note the epoch is midnight GMT = 7pm local time here.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Extracting date from epoche
2001-06-19 15:46 Extracting date from epoche Najm Hashmi <najm@flipr.com>
2001-06-21 09:11 ` Re: Extracting date from epoche Richard Huxton <dev@archonet.com>
2001-06-21 14:05 ` Re: Extracting date from epoche Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-06-21 17:47 ` Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 4+ messages in thread
From: Richard Huxton @ 2001-06-21 17:47 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql; Najm Hashmi <najm@flipr.com>
From: "Tom Lane" <tgl@sss.pgh.pa.us>
> "Richard Huxton" <dev@archonet.com> writes:
> > Tom - I thought 'epoch'::timestamp should work too - good reason, or
just
> > One Of Those Things (tm)?
>
> It works --- it's a symbolic value, though.
>
> regression=# select 'epoch'::timestamp;
> ?column?
> ----------
> epoch
> (1 row)
>
> regression=# select 'epoch'::timestamp + ('1 day'::interval);
> ?column?
> ------------------------
> 1970-01-01 19:00:00-05
> (1 row)
Ah - problem is in my wetware then. That's ok.
- Richard Huxton
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2001-06-21 17:47 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-19 15:46 Extracting date from epoche Najm Hashmi <najm@flipr.com>
2001-06-21 09:11 ` Richard Huxton <dev@archonet.com>
2001-06-21 14:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-06-21 17:47 ` Richard Huxton <dev@archonet.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox