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

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

collision detection - C++ library for mesh to mesh intersection: what is available? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -