postgresql - How to subtract seconds from postgres datetime -
say have column of type datetime value "2014-04-14 12:17:55.772" & need subtract seconds "2" seconds o/p "12:17:53".
select '2014-04-14 12:17:55.772'::timestamp - interval '2 seconds';
for greater flexibility possible mutiply interval
select '2014-04-14 12:17:55.772'::timestamp - 2 * interval '1 second';
if want truncate second
select date_trunc( 'second', '2014-04-14 12:17:55.772'::timestamp - interval '2 seconds' );
Comments
Post a Comment