Re: [HACKERS] getting at the actual int4 value of an abstime - Mailing list pgsql-hackers

From jim@reptiles.org (Jim Mercer)
Subject Re: [HACKERS] getting at the actual int4 value of an abstime
Date
Msg-id m11H5qY-00080YC@mailbox.reptiles.org
Whole thread Raw
In response to Re: [HACKERS] getting at the actual int4 value of an abstime  ("Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu>)
Responses Re: [HACKERS] getting at the actual int4 value of an abstime
List pgsql-hackers
> test=> select timefield::int8 from timetest;
>      int8
> ---------
> 934931603
> 934931604
> 934931605
> (3 rows)

hmmm, as you did, i tried timefield::int4, and got the same results.
i hadn't tried timefield::int8.

i suspect this would be more efficient than date_part('epoch', timefield).

> What version of PostgreSQL, BTW? This is 6.5: int8 and numeric support got a
> lot better vs. 6.4

i am using 6.5, soon gonna upgrade to 6.5.1.

thanx, this will make my code much more efficient.

also, is there a reverse to this?

ie.  how does one inject unix time_t data into an abstime field.

i currently pass my raw data through a filter, which converts it
to 'yyyy-mm-dd HH:MM:SS'.

then i bring it in using: "COPY tb USING STDIN;"

it would be nice if i could do a batch of:
"INSERT INTO tb (time_t, data1, date2) VALUES (934931604, 'aa', 'bb');"

--
[ Jim Mercer    Reptilian Research      jim@reptiles.org   +1 416 410-5633 ]
[ The telephone, for those of you who  have forgotten, was a commonly used ]
[ communications technology in the days before electronic mail.            ]
[ They're still easy to find in most large cities. -- Nathaniel Borenstein ]

pgsql-hackers by date:

Previous
From: "D'Arcy" "J.M." Cain
Date:
Subject: Re: [HACKERS] Re: [CORE] Re: tomorrow
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] Re: [CORE] Re: tomorrow