Ask a Question related to PostgreSQL / PGSQL, Design and Development.
-
Roman Neuhauser #1
int4 -> unix timestamp -> sql timestamp; abstime?
Hello,
what is the opposite of cast(extract('epoch' from now()) as int)?
The only thing I found that works is
cast(cast(... as abstime) as timestamp)
and the documentation says abstime shouldn't be used, and may
disappear. What should I use instead?
--
FreeBSD 4.10-STABLE
12:01AM up 15:39, 7 users, load averages: 0.08, 0.04, 0.01
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
[url]http://www.postgresql.org/docs/faqs/FAQ.html[/url]
Roman Neuhauser Guest
-
Unix timestamp values
Is there a CF function to convert unix timestamp values to dates? I'm not talking about the {ts #######} style timestamps, but the "seconds from the... -
Date comparisons using UNIX timestamp?
Hi all, How does one compare dates if one (or both) of the dates is before 1/1/1970? I tried converting the user's input (from selection boxes;... -
Concerting a Date Object into a UNIX Timestamp
Hello beloved Ruby-Community, maybe a stupid question because I probably missed something reading the reference of "Programming Ruby", but how do... -
convert UNIX timestamp
Hi Scott, All How can I reverse this ? ( Convert date/time format to UNIX timestamp ) Thanks! Jason. Hall, Scott wrote: -
[PHP] convert mysql datetime to unix timestamp
Tried passing it through strtotime? Example: echo(date('U',strtotime($string))); On Mon, 2003-07-28 at 12:06, Chris Hayes (SENSE) wrote: --... -
Tom Lane #2
Re: int4 -> unix timestamp -> sql timestamp; abstime?
Roman Neuhauser <neuhauser@chello.cz> writes:
The recommended locution is> what is the opposite of cast(extract('epoch' from now()) as int)?
> The only thing I found that works is
> cast(cast(... as abstime) as timestamp)
> and the documentation says abstime shouldn't be used, and may
> disappear. What should I use instead?
SELECT TIMESTAMP WITH TIME ZONE 'epoch' + <x> * INTERVAL '1 second';
Of course you can wrap this up in a function if you prefer (not sure why
we haven't done so already).
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [email]majordomo@postgresql.org[/email]
Tom Lane Guest
-
Michael Glaesemann #3
Re: int4 -> unix timestamp -> sql timestamp; abstime?
On Jan 12, 2005, at 8:35, Tom Lane wrote:
It's in the queue for 8.1.> The recommended locution is
>
> SELECT TIMESTAMP WITH TIME ZONE 'epoch' + <x> * INTERVAL '1 second';
>
> Of course you can wrap this up in a function if you prefer (not sure
> why
> we haven't done so already).
<http://candle.pha.pa.us/mhonarc/patches2/msg00090.html>
Michael Glaesemann
grzm myrealbox com
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
Michael Glaesemann Guest
-
Roman Neuhauser #4
Re: int4 -> unix timestamp -> sql timestamp; abstime?
# [email]tgl@sss.pgh.pa.us[/email] / 2005-01-11 18:35:18 -0500:
Have I missed this in the manual?> Roman Neuhauser <neuhauser@chello.cz> writes:>> > what is the opposite of cast(extract('epoch' from now()) as int)?
> > The only thing I found that works is
> > cast(cast(... as abstime) as timestamp)
> > and the documentation says abstime shouldn't be used, and may
> > disappear. What should I use instead?
> The recommended locution is
>
> SELECT TIMESTAMP WITH TIME ZONE 'epoch' + <x> * INTERVAL '1 second';
I most surely will, and I'm glad to hear this will be included in 8.1.> Of course you can wrap this up in a function if you prefer (not sure why
> we haven't done so already).
Thanks for the replies!
--
FreeBSD 4.10-STABLE
1:25AM up 17:04, 9 users, load averages: 0.11, 0.06, 0.01
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [email]majordomo@postgresql.org[/email])
Roman Neuhauser Guest
-
Tom Lane #5
Re: int4 -> unix timestamp -> sql timestamp; abstime?
Roman Neuhauser <neuhauser@chello.cz> writes:
>> The recommended locution is
>>
>> SELECT TIMESTAMP WITH TIME ZONE 'epoch' + <x> * INTERVAL '1 second';The 8.0 docs mention this in the discussion of extract(epoch), but I'm> Have I missed this in the manual?
not sure if it was there before. It's been discussed in the mailing
list archives many times...
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
Tom Lane Guest
-
David Fetter #6
Re: int4 -> unix timestamp -> sql timestamp; abstime?
On Tue, Jan 11, 2005 at 06:35:18PM -0500, Tom Lane wrote:
I think this should read:> Roman Neuhauser <neuhauser@chello.cz> writes:>> > what is the opposite of cast(extract('epoch' from now()) as int)?
> > The only thing I found that works is
> > cast(cast(... as abstime) as timestamp)
> > and the documentation says abstime shouldn't be used, and may
> > disappear. What should I use instead?
> The recommended locution is
>
> SELECT TIMESTAMP WITH TIME ZONE 'epoch' + <x> * INTERVAL '1 second';
SELECT TIMESTAMP WITH TIME ZONE 'epoch' AT TIME ZONE 'UTC' + <x> * INTERVAL '1 second';
/* ^^^^^^^^^^^^^^^^^^ */
to conform with the *n*x standard.
Cheers,
D
--
David Fetter [email]david@fetter.org[/email] [url]http://fetter.org/[/url]
phone: +1 510 893 6100 mobile: +1 415 235 3778
Remember to vote!
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
[url]http://www.postgresql.org/docs/faqs/FAQ.html[/url]
David Fetter Guest
-
Tom Lane #7
Re: int4 -> unix timestamp -> sql timestamp; abstime?
David Fetter <david@fetter.org> writes:
>> The recommended locution is
>>
>> SELECT TIMESTAMP WITH TIME ZONE 'epoch' + <x> * INTERVAL '1 second';> I think this should read:It's correct as written; your modification throws it off by the local GMT> SELECT TIMESTAMP WITH TIME ZONE 'epoch' AT TIME ZONE 'UTC' + <x> * INTERVAL '1 second';
> /* ^^^^^^^^^^^^^^^^^^ */
offset.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
[url]http://archives.postgresql.org[/url]
Tom Lane Guest
-
Roman Neuhauser #8
Re: int4 -> unix timestamp -> sql timestamp; abstime?
# [email]tgl@sss.pgh.pa.us[/email] / 2005-01-11 19:31:19 -0500:
My searches on google.com and of the postresql.org documentation sets> Roman Neuhauser <neuhauser@chello.cz> writes:>> >> The recommended locution is
> >>
> >> SELECT TIMESTAMP WITH TIME ZONE 'epoch' + <x> * INTERVAL '1 second';>> > Have I missed this in the manual?
> The 8.0 docs mention this in the discussion of extract(epoch), but I'm
> not sure if it was there before. It's been discussed in the mailing
> list archives many times...
haven't turned anything up. Any chance of this getting into the 7.4
docs?
--
FreeBSD 4.10-STABLE
1:53AM up 17:31, 9 users, load averages: 0.05, 0.03, 0.00
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
[url]http://www.postgresql.org/docs/faqs/FAQ.html[/url]
Roman Neuhauser Guest
-
David Fetter #9
Re: int4 -> unix timestamp -> sql timestamp; abstime?
On Tue, Jan 11, 2005 at 07:44:46PM -0500, Tom Lane wrote:
Thanks for the heads-up. I was just about to Do The Wrong Thing(TM)> David Fetter <david@fetter.org> writes:>> >> The recommended locution is
> >>
> >> SELECT TIMESTAMP WITH TIME ZONE 'epoch' + <x> * INTERVAL '1 second';>> > I think this should read:>> > SELECT TIMESTAMP WITH TIME ZONE 'epoch' AT TIME ZONE 'UTC' + <x> * INTERVAL '1 second';
> > /* ^^^^^^^^^^^^^^^^^^ */
> It's correct as written; your modification throws it off by the
> local GMT offset.
in a doc patch re: ALTER COLUMN TYPE :)
Cheers,
D
--
David Fetter [email]david@fetter.org[/email] [url]http://fetter.org/[/url]
phone: +1 510 893 6100 mobile: +1 415 235 3778
Remember to vote!
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [email]majordomo@postgresql.org[/email])
David Fetter Guest



Reply With Quote

