Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Number of quarters between 2 dates

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I would use pandas for this

import pandas as pd

print(len(pd.date_range('2020Q1', '2022Q4', freq="Q")))  # -> 11
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading