select current_timestamp(6), current_timestamp(0)
----------------------------------------------------
2012-02-22 16:03:45.988418+13 | 2012-02-22 16:03:46+13
-------^ ------------^ (date from the future)
This query can easily return the timestamp from the future for the second column because of current_timestamp(0) is rounding “mathematically”. This could lead to some unexpected errors, just because the retrieved time is from the future up to 0.5s.
So my question is – what is the simplest way to round current_timestamp(6) to the nearest second down?
PS: I know the solution with converting to seconds and back
PPS: The result should be a timestamp type, not a string
UPD:
Found a solution
select current_timestamp(6), current_timestamp(0)::abstime
1 Answer