pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feeda question about dates and timestamp
5+ messages / 3 participants
[nested] [flat]
* a question about dates and timestamp
@ 2000-08-03 08:24 Ange Michel POZZO <poange@technologist.com>
2000-08-03 08:58 ` Re: a question about dates and timestamp Karel Zak <zakkr@zf.jcu.cz>
0 siblings, 1 reply; 5+ messages in thread
From: Ange Michel POZZO @ 2000-08-03 08:24 UTC (permalink / raw)
To: pgsql-sql
hi all
i have a table like this
id_message int4 not null default nextval ( ...
id_abonne int4
texte_message varchar() not null
date_message numeric not null
the default size of numeric is 30.6
another table :
id_message int4
id_abonne int4
text_message text
date_message int4
in both case date_message is used to store a unix timestamp ( number of seconds
since 1st of 1970)
for example : 965340000 = 2000-08-03 00:00:00+02
my question is how can i convert the numeric or the int4 value to a date value?
which function should i use to make something like this work ?
select convert_to_date( date_message) from my_table;
2000-08-03 00:00:00+02
2000-08-01 13:56:00+02
etc etc
thanks in advance
Pozzo Ange
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: a question about dates and timestamp
2000-08-03 08:24 a question about dates and timestamp Ange Michel POZZO <poange@technologist.com>
@ 2000-08-03 08:58 ` Karel Zak <zakkr@zf.jcu.cz>
2000-08-03 09:30 ` Re: a question about dates and timestamp Ange Michel POZZO <poange@technologist.com>
0 siblings, 1 reply; 5+ messages in thread
From: Karel Zak @ 2000-08-03 08:58 UTC (permalink / raw)
To: Ange Michel POZZO <poange@technologist.com>; +Cc: pgsql-sql
> my question is how can i convert the numeric or the int4 value to
> a date value?
test=# select abstime(965293003);
abstime
------------------------
2000-08-03 10:56:43+02
(1 row)
Karel
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: a question about dates and timestamp
2000-08-03 08:24 a question about dates and timestamp Ange Michel POZZO <poange@technologist.com>
2000-08-03 08:58 ` Re: a question about dates and timestamp Karel Zak <zakkr@zf.jcu.cz>
@ 2000-08-03 09:30 ` Ange Michel POZZO <poange@technologist.com>
2000-08-03 10:39 ` Re: a question about dates and timestamp Karel Zak <zakkr@zf.jcu.cz>
2000-08-03 15:20 ` Re: a question about dates and timestamp Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 5+ messages in thread
From: Ange Michel POZZO @ 2000-08-03 09:30 UTC (permalink / raw)
To: Karel Zak <zakkr@zf.jcu.cz>; +Cc: pgsql-sql
Le jeu, 03 aoû 2000, Karel Zak a écrit :
> > my question is how can i convert the numeric or the int4 value to
> > a date value?
>
>
> test=# select abstime(965293003);
> abstime
> ------------------------
> 2000-08-03 10:56:43+02
> (1 row)
>
> Karel
this is the result of the query for me :
test=> select abstime(965293003);
?column?
---------
965293003
(1 row)
i must do :
select datetime(abstime( value )); if value is a int4 work ok
but for a numeric, it don't work
i have tried to convert a numeric to int4
with floor, int4, numeric_int4 nothing work !
select datetime(abstime( floor (value) ));
select datetime(abstime( int4 (value) ));
select datetime(abstime( numeric_int4 (value) ));
in all case :
ERROR: pg_atoi: error in "952969611.000000": can't parse ".000000"
what is the way to convert numeric to int4 ?
i know this is'nt a good choise to store timestamp in a int4 or numeric value,
but i found the database like this and know i can't change this :(
thanks
POZZO ange
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: a question about dates and timestamp
2000-08-03 08:24 a question about dates and timestamp Ange Michel POZZO <poange@technologist.com>
2000-08-03 08:58 ` Re: a question about dates and timestamp Karel Zak <zakkr@zf.jcu.cz>
2000-08-03 09:30 ` Re: a question about dates and timestamp Ange Michel POZZO <poange@technologist.com>
@ 2000-08-03 10:39 ` Karel Zak <zakkr@zf.jcu.cz>
1 sibling, 0 replies; 5+ messages in thread
From: Karel Zak @ 2000-08-03 10:39 UTC (permalink / raw)
To: Ange Michel POZZO <poange@technologist.com>; +Cc: pgsql-sql
On Thu, 3 Aug 2000, Ange Michel POZZO wrote:
> Le jeu, 03 aoű 2000, Karel Zak a écrit :
> > > my question is how can i convert the numeric or the int4 value to
> > > a date value?
> >
> >
> > test=# select abstime(965293003);
> > abstime
> > ------------------------
> > 2000-08-03 10:56:43+02
> > (1 row)
> >
> > Karel
>
>
> this is the result of the query for me :
>
> test=> select abstime(965293003);
> ?column?
> ---------
> 965293003
> (1 row)
Ooops I use CVS version, but you have probably 6.5...
Sorry, Now I haven't time check what is 7.1 / 7.0 / 6.5 feature.
in current code:
test=# select '965293003.000001'::int;
ERROR: pg_atoi: error in "965293003.000001": can't parse ".000001"
test=# select '965293003.000001'::numeric(9, 0);
?column?
-----------
965293003
(1 row)
test=# select '965293003.000001'::numeric(9, 0)::int;
?column?
-----------
965293003
(1 row)
test=# select abstime('965293003.000001'::numeric(9, 0)::int);
abstime
------------------------
2000-08-03 10:56:43+02
(1 row)
BTW. The postgreSQL has good date/time support; why you use slow and
expensive numeric?
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: a question about dates and timestamp
2000-08-03 08:24 a question about dates and timestamp Ange Michel POZZO <poange@technologist.com>
2000-08-03 08:58 ` Re: a question about dates and timestamp Karel Zak <zakkr@zf.jcu.cz>
2000-08-03 09:30 ` Re: a question about dates and timestamp Ange Michel POZZO <poange@technologist.com>
@ 2000-08-03 15:20 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 5+ messages in thread
From: Tom Lane @ 2000-08-03 15:20 UTC (permalink / raw)
To: poange@technologist.com; +Cc: Karel Zak <zakkr@zf.jcu.cz>; pgsql-sql
Ange Michel POZZO <poange@technologist.com> writes:
> select datetime(abstime( floor (value) ));
> select datetime(abstime( int4 (value) ));
> select datetime(abstime( numeric_int4 (value) ));
> in all case :
> ERROR: pg_atoi: error in "952969611.000000": can't parse ".000000"
That was fixed in January. Update to 7.0 and it'll work fine.
You might be able to make it work in 6.5 like this:
abstime(int4(float8(numeric)))
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2000-08-03 15:20 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-08-03 08:24 a question about dates and timestamp Ange Michel POZZO <poange@technologist.com>
2000-08-03 08:58 ` Karel Zak <zakkr@zf.jcu.cz>
2000-08-03 09:30 ` Ange Michel POZZO <poange@technologist.com>
2000-08-03 10:39 ` Karel Zak <zakkr@zf.jcu.cz>
2000-08-03 15:20 ` Tom Lane <tgl@sss.pgh.pa.us>
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