Обсуждение: biginteger to timestamp

Поиск
Список
Период
Сортировка

biginteger to timestamp

От
LiveShell
Дата:
Hi all,
         I want to convert biginteger and integer data type to timestamp data type.
Can any body tell me how to convert??

Re: biginteger to timestamp

От
Peter Eisentraut
Дата:
Am Donnerstag, 20. Juli 2006 11:26 schrieb LiveShell:
>          I want to convert biginteger and integer data type to timestamp
> data type.

That depends mostly on what kind of meaning you intend to attach to an integer
N.   If you want seconds since 1970, you could do

x * interval '1 second' + timestamp '1970-01-01'

For other meanings, adjust as necessary.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: biginteger to timestamp

От
"hubert depesz lubaczewski"
Дата:
On 7/20/06, LiveShell <liveshell@gmail.com> wrote:
Hi all,
         I want to convert biginteger and integer data type to timestamp data type.
Can any body tell me how to convert??

and what is in this biginteger?
is it something like:
20060720113254::bigint
or rather something like "seconds from epoch"?
or something totally different?

depesz

--
http://www.depesz.com/ - nowy, lepszy depesz

Re: biginteger to timestamp

От
LiveShell
Дата:
hi hubert
actally i have UNIX time and that is in 1153222974  format. and i m using C api to insert this time in a column whose type is timestamp.
so now can u tell me .... how can i convert it to timestamp and insert into the timestamp column.

 
On 7/20/06, hubert depesz lubaczewski <depesz@gmail.com> wrote:
On 7/20/06, LiveShell < liveshell@gmail.com> wrote:
Hi all,
         I want to convert biginteger and integer data type to timestamp data type.
Can any body tell me how to convert??

and what is in this biginteger?
is it something like:
20060720113254::bigint
or rather something like "seconds from epoch"?
or something totally different?

depesz

--
http://www.depesz.com/ - nowy, lepszy depesz

Re: biginteger to timestamp

От
"Ben K."
Дата:
> actally i have UNIX time and that is in *1153222974*  format. and i m using

select to_timestamp(1153222974);
http://www.postgresql.org/docs/8.1/static/functions-formatting.html

if you're on 8.1.

HTH.

Ben K.
Developer
http://benix.tamu.edu

Re: biginteger to timestamp

От
Bruno Wolff III
Дата:
On Thu, Jul 20, 2006 at 15:11:35 +0530,
  LiveShell <liveshell@gmail.com> wrote:
> hi hubert
> actally i have UNIX time and that is in *1153222974*  format. and i m using
> C api to insert this time in a column whose type is timestamp.
> so now can u tell me .... how can i convert it to timestamp and insert into
> the timestamp column.

Note that you should be using "timestamp with time zone" (timestamptz) for
this rather than "timestamp".