First day of the calendar quarter

Wednesday 18 July 2018 @ 9:53 pm

Finding the the beginning date for most date periods is simple. For example:
First day of this Year: Minimum (YearToDate)
First day of this month: Minimum (MonthToDate)
First day of Last month: Minimum (LastFullMonth)
First day of this week: Minimum (WeekToDate)

But there isn’t a comparably simple way to get the first day of the current calendar quarter. So if you ever need that calculation you can use the following formula:

Local numberVar x := Month (CurrentDate);
Date (
Year(CurrentDate), //Year
if x > 9 then 10 else
if x > 6 then 7 else
if x > 3 then 4 else 1, //Month
1 //Day
)

If you want the beginning of the quarter related to a field other than today’s date you can substitute a database field, formula or parameter in the two places that say “CurrentDate”.

(For examples of my most popular formulas, please visit the FORMULAS page on my website.)






Comments are closed.

Jeff-Net
Recrystallize Pro

Crystal Reports Server