littleK littleK - 1 year ago 58
SQL Question

Remove TIMESTAMP precision from NOW() result in PostgreSQL?

Is there any way to remove the precision from the result of the NOW() function in PostgreSQL?

"2012-08-21 10:23:34.867502"

I'm looking for the format to be:

"2012-08-21 10:23:34"

I'm attempting to update a column of type "timestamp without time zone" with the following SQL:

UPDATE table SET column = now();


Answer Source
UPDATE tbl SET col = DATE_TRUNC('second', NOW());

See the docs for DATE_TRUNC.