Number of quarters between 2 dates
Question:
Let say I have 2 dates in below format
date1 = '2020Q1'
date2 = '2022Q4'
I want to calculate number of quarter between these 2 dates as integer.
Is there any method available to perform this?
Answers:
I would use pandas for this
import pandas as pd
print(len(pd.date_range('2020Q1', '2022Q4', freq="Q"))) # -> 11
Let say I have 2 dates in below format
date1 = '2020Q1'
date2 = '2022Q4'
I want to calculate number of quarter between these 2 dates as integer.
Is there any method available to perform this?
I would use pandas for this
import pandas as pd
print(len(pd.date_range('2020Q1', '2022Q4', freq="Q"))) # -> 11