How can I calculate the number of months between two YYYYMM integer values in Postgresql?
DATA:
| Date1 | Date2 |
|--------|--------|
| 201608 | 201702 |
| 201609 | 201610 |
DESIRED OUTPUT:
| Date1 | Date2 | MonthsBetweenInclusive | MonthsBetweenExclusive |
|--------|--------|------------------------|------------------------|
| 201608 | 201702 | 7 | 6 |
| 201609 | 201610 | 2 | 1 |
I have looked at the PostgreSQL date function documentation but I'm unable to find a solution that operates on YYYYMM integer values.