timestamp to int

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

timestamp to int

От:
Edwin Grubbs <egrubbs@rackspace.com>
Дата:
Is there any function for converting a timestamp into an integer with the
unix seconds value? It's really easy to convert in the other direction.

-Edwin

Re: timestamp to int

От:
"Mitch Vincent" <mvincent@cablespeed.com>
Дата:
SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40');

-- and you can replace the timestamp string with the name of a timestamp
column.

The above is in the manual, BTW.

-Mitch

----- Original Message -----
From: "Edwin Grubbs" 
To: 
Sent: Tuesday, June 26, 2001 11:16 AM
Subject: [GENERAL] timestamp to int


> Is there any function for converting a timestamp into an integer with the
> unix seconds value? It's really easy to convert in the other direction.
>
> -Edwin
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

Re: timestamp to int

От:
Tomas Berndtsson <tomas@nocrew.org>
Дата:
"Mitch Vincent"  writes:

> SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40');
> 
> -- and you can replace the timestamp string with the name of a timestamp
> column.
> 
> The above is in the manual, BTW.

Is there a way to do it the other way around, from an integer to a
timestamp?


Tomas

Re: timestamp to int

От:
will trillich <will@serensoft.com>
Дата:
On Tue, Jun 26, 2001 at 09:22:25PM +0200, Tomas Berndtsson wrote:
> "Mitch Vincent"  writes:
> 
> > SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40');
> > 
> > -- and you can replace the timestamp string with the name of a timestamp
> > column.
> > 
> > The above is in the manual, BTW.
> 
> Is there a way to do it the other way around, from an integer to a
> timestamp?

of course not. don't be silly.

certainly not date_part or to_char or to_date. they're not
mentioned in the docs, either, so don't bother looking.
(think of the time you'll save.)

in particular, on my debian system, you wouldn't look in
/usr/share/doc/postgresql-doc/html/postgres/postgres.htm
and you wouldn't do

	cd /usr/share/doc/postgresql-doc/html/postgres
	grep -i epoch *

that would be bad.

-- 
I'd concentrate on "living in the now" because it is fun
and on building a better world because it is possible.
	- Tod Steward

will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Re: timestamp to int

От:
Tomas Berndtsson <tomas@nocrew.org>
Дата:
will trillich  writes:

> On Tue, Jun 26, 2001 at 09:22:25PM +0200, Tomas Berndtsson wrote:
> > Is there a way to do it the other way around, from an integer to a
> > timestamp?
> 
> of course not. don't be silly.
> 
> certainly not date_part or to_char or to_date. they're not
> mentioned in the docs, either, so don't bother looking.
> (think of the time you'll save.)
> 
> in particular, on my debian system, you wouldn't look in
> /usr/share/doc/postgresql-doc/html/postgres/postgres.htm
> and you wouldn't do
> 
> 	cd /usr/share/doc/postgresql-doc/html/postgres
> 	grep -i epoch *
> 
> that would be bad.

I sense a touch of sarcasm. Yet, having looked (yes, before I mailed,
and now again after), I still can't find a way to create a timestamp
from an integer. You may call me stupid, but I'd be glad to see how
it's done.


Tomas

Re: timestamp to int

От:
Alex Pilosov <alex@pilosoft.com>
Дата:
On 30 Jun 2001, Tomas Berndtsson wrote:

> > certainly not date_part or to_char or to_date. they're not
> > mentioned in the docs, either, so don't bother looking.
> > (think of the time you'll save.)
> > 
> > in particular, on my debian system, you wouldn't look in
> > /usr/share/doc/postgresql-doc/html/postgres/postgres.htm
> > and you wouldn't do
> > 
> > 	cd /usr/share/doc/postgresql-doc/html/postgres
> > 	grep -i epoch *
> > 
> > that would be bad.
> 
> I sense a touch of sarcasm. Yet, having looked (yes, before I mailed,
> and now again after), I still can't find a way to create a timestamp
> from an integer. You may call me stupid, but I'd be glad to see how
> it's done.
Quite strangely, there's no argument for to_date to do conversion from
'seconds since epoch'. At any case, this is how you do it:

select 'epoch'::timestamp + (x || ' seconds')::interval

-alex

Re: timestamp to int

От:
Tomas Berndtsson <tomas@nocrew.org>
Дата:
Alex Pilosov  writes:

> On 30 Jun 2001, Tomas Berndtsson wrote:
> 
> > > certainly not date_part or to_char or to_date. they're not
> > > mentioned in the docs, either, so don't bother looking.
> > > (think of the time you'll save.)
> > > 
> > > in particular, on my debian system, you wouldn't look in
> > > /usr/share/doc/postgresql-doc/html/postgres/postgres.htm
> > > and you wouldn't do
> > > 
> > > 	cd /usr/share/doc/postgresql-doc/html/postgres
> > > 	grep -i epoch *
> > > 
> > > that would be bad.
> > 
> > I sense a touch of sarcasm. Yet, having looked (yes, before I mailed,
> > and now again after), I still can't find a way to create a timestamp
> > from an integer. You may call me stupid, but I'd be glad to see how
> > it's done.
> Quite strangely, there's no argument for to_date to do conversion from
> 'seconds since epoch'. At any case, this is how you do it:
> 
> select 'epoch'::timestamp + (x || ' seconds')::interval

Thank you. That wasn't too obvious to me, but quite logical when
seeing it now.


Tomas
FAQ