Search code examples
crystal-reports

Get last day of the next three months with Crystal Report


I am heading to find out a formula for a date that is the last day of the next 3 months with Crystal Report. I've tried with the code as below but it shows a message when it is out of an array of month (1-12). Please give me any advice to address this problem.

ToText(date(year({rptIEXSaleInvoiceSummary.ETD}),month({rptIEXSaleInvoiceSummary.ETD})+4,1)-1, "dd-MMM-yyyy")

It works fine if the ETD's month is less than 8. However, it might cause problem when it is more than 9, 10 as an image below.

1


Solution

  • I've found the solution. Please let me know if you have any idea to solve the problem.

    IF (month({rptIEXSaleInvoiceSummary.ETD})+4) > 12 THEN 
    ToText(date(year({rptIEXSaleInvoiceSummary.ETD})+1,month({rptIEXSaleInvoiceSummary.ETD})-8,1)-1, "dd-MMM-yyyy")
    ELSE
    ToText(date(year({rptIEXSaleInvoiceSummary.ETD}),month({rptIEXSaleInvoiceSummary.ETD})+4,1)-1, "dd-MMM-yyyy")