Calculate time intervals in months ( Date List )

Asked

Viewed 44 times

0

I have a Date List

01.01.2017 13-month interval 02.02.2018 period of 14 months 03.04.2019 interval of 8 months 19.12.2019

Is there any way to make a select that returns months between listed dates I already found some answers here on the forum more their example is always between two dates not intervening from several dates listed

The question is to know if you have how to solve with a Select.. otherwise we will have to develop a function for this purpose...

Thank you

  • In Postgresql you can use the function age. From the result (an interval) extract the year, multiply by 12, and add to the months also extracted. If you want to determine the new date by adding a range just add/subtract the interval to the original date.

  • That’s not quite what I want... it shows the difference of the record list with today’s date... I want the difference between the records.. listed.. or got it wrong ??

  • Use the function age with two parameters: start timestamp and end timestamp.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.