I'm new to CR and need a formula that would give me the end of the month a on a date field. If the Date is 628/2012 or 7/12/2012 I need the formula to to be the end of the month no matter which day of the month the field shows. Of course we know that not every month ends on the 30th or 31th and February sometimes 29th or 30th. So what formula can I use to do this
Example field name {table.end_date}
Any help is greatly appreciated.
Thanks in advance.
Create a formula field to calculate the end of the month:
//{@EndOfMonth}
// find the first day of the month, add a month to it, then subtract a day
DateAdd("m", 1, DateTime( Year({table.dateField}), Month({table.dateField}), 1, 0,0,0 )) - 1
Create a second formula that will generate a textual representation:
//{@TextRepresentation}
If Isnull({table.end_date}) Then
Space(8)
Else
ToText({@EndOfMonth}, "YYYYMMDD")
来源:https://stackoverflow.com/questions/11837372/crystal-report-date-formula-to-make-it-the-end-of-the-month