Crystal Reports How To — Get First Day and Last Day of Month Based On Month Number E.g. 1
Crystal Reports How To — Get First Day and Last Day of Month Based On Month Number E.g. 1
Scenario:
Get the first day and last day of month based on Month Integer E.g. 1 for January
1. Create Formula in Crystal called ‘Month’. User will enter or select 1 for January. Use the ‘Value’ and ‘Description’ fields.
2. Create a Formula ‘StartOfMonth’ — Date(year(currentdate), {?Month},1)
3. Create a Formula ‘EndOfMonth’ — dateadd(“m”, 1, {@StartOfMonth})-1
Check the output by adding the formulas to the report.
4. In ‘Selection Formula’, add the following -
({Command.Post Date} >= {@StartOfMonth} and{Command.Post Date} <= {@EndOfMonth})