I have 5 time unit, namely: Day, Week, Month, Quarter, Year.
How do I write a function to calculate the number of periods between 2 time units? For example,
number of Days in a Month --> should be either 28, 29, 30 or 31 days depend on the month.
number of Days in a Year --> should be either 365 or 366 days depends on if the year is a leap year.
number of Months in a Year --> 12 months.
number of Quarter in a Year --> 4 Quarters.
number of Weeks in a month --> Maybe 4 or 5 weeks.
etc..
I know I can do it using brute-force method. However, is there any better way to do it?
Thanks in advance!