Reputation: 121
I'm struggling to return a date with milliseconds...
I've tried
my_date::datetime
and
my_date::timestamp
but both only return to the second?
Surely there's a way of doing this? Documentation isn't too helpful!
Thanks
Upvotes: 0
Views: 93
Reputation: 34053
The my_date
column also has to contain the millisecond component (I'm assuming that it's of a timestamp
type). Have you verified that it does?
dbadmin=> CREATE TABLE date_test (my_date timestamp);
CREATE TABLE
dbadmin=> INSERT INTO date_test (my_date) VALUES (SYSDATE());
OUTPUT
--------
1
(1 row)
dbadmin=> INSERT INTO date_test (my_date) VALUES ('2015-01-30 09:43:41');
OUTPUT
--------
1
(1 row)
dbadmin=> COMMIT;
COMMIT
dbadmin=> SELECT my_date::timestamp FROM date_test;
my_date
----------------------------
2015-01-30 09:46:48.746415
2015-01-30 09:43:41
(2 rows)
Upvotes: 1