Обсуждение: timestamp- milliseconds since epoch output
Hi, I'm using a timestamp field called date_created. Whenever I select it I get: select date_created from tbl_user; date_created ------------------------2001-02-05 17:23:26-082001-02-05 17:45:39-082001-02-03 03:58:53-08 (3 rows) I've tried using variations of to_char and to_timestamp but can't seem to get the timestamp as a value of milliseconds since the Epoch (Jan 1, 1970). I've been looking through the user manual but can't seem to find anything... might be nice to put it in there as this is probably a very common operation. Any ideas? Thanks, Jamu. -- Jamu Kakar (Developer) Expressus Design Studio, Inc. jkakar@expressus.com 708-1641 Lonsdale Avenue V: (604) 903-6994 North Vancouver, BC, V7M 2J5
On Tue, 6 Feb 2001 jkakar@expressus.com wrote: > Hi, > > I'm using a timestamp field called date_created. Whenever I select it > I get: > > select date_created from tbl_user; > date_created > ------------------------ > 2001-02-05 17:23:26-08 > 2001-02-05 17:45:39-08 > 2001-02-03 03:58:53-08 > (3 rows) > > I've tried using variations of to_char and to_timestamp but can't seem > to get the timestamp as a value of milliseconds since the Epoch (Jan to_char() and to_timestamp() are milliseconds ignorant routines. It's in my TODO list for next release -- now we in feature freeze state. Karel
jkakar@expressus.com writes: > I've tried using variations of to_char and to_timestamp but can't seem > to get the timestamp as a value of milliseconds since the Epoch (Jan > 1, 1970). regression=# select date_part('epoch','2001-02-05 17:23:26.123456-08'::timestamp); date_part ------------------981422606.123456 (1 row) Multiply by 1000 if you feel a strong urge to have it in milliseconds... regards, tom lane