Reputation: 5049
In PostgreSQL I could do the formatting of a timestamp to seconds as follows.
to_timestamp('2017-02-20 08:22:44.166', 'YYYY-MM-DD HH24:MI:SS') --> 2017-02-20 08:22:44
I need to format the above time stamp into 100s and 10s of seconds.
--> 2017-02-20 08:22:44.17
(formatted to 1/100s of second)
--> 2017-02-20 08:22:44.2
(formatted to 1/10 th of second)
Upvotes: 1
Views: 79
Reputation: 121594
Cast a value to timestamp with a specified precision:
select '2017-02-20 08:22:44.166'::timestamp(2), '2017-02-20 08:22:44.166'::timestamp(1)
timestamp | timestamp
------------------------+-----------------------
2017-02-20 08:22:44.17 | 2017-02-20 08:22:44.2
(1 row)
Upvotes: 2