Answers for "calculate time between following date postgresql"

SQL
0

DATEDIFF minute postgres

-- Difference between Dec 30, 2011 08:54:55 and  Dec 30, 2011 08:56:10 in minutes
  SELECT (DATE_PART('day', '2011-12-30 08:56:10'::timestamp - '2011-12-30 08:54:55'::timestamp) * 24 * 60 + 
               DATE_PART('hour', '2011-12-30 08:56:10'::timestamp - '2011-12-30 08:54:55'::timestamp)) * 60 +
               DATE_PART('minute', '2011-12-30 08:56:10'::timestamp - '2011-12-30 08:54:55'::timestamp);
  -- Result: 1
 
  -- Time only
  SELECT DATE_PART('hour', '08:56:10'::time - '08:54:55'::time) * 60 +
              DATE_PART('minute', '08:56:10'::time - '08:54:55'::time);
  -- Result: 1
Posted by: Guest on February-25-2020
0

substract variable amount of minutes from timestamp postgresql

SELECT p.date_time + number_of_seconds * INTERVAL '1 second'
    FROM photo p 
    WHERE p.id = 1;
Posted by: Guest on October-16-2020

Code answers related to "calculate time between following date postgresql"

Code answers related to "SQL"

Browse Popular Code Answers by Language