Search code examples
datecrystal-reports

Produce 1 month of current date and +1 month of current date


My formula needs to calculated values for 1 month of current date and/or +1 month of current date. I know the following formula returns values up to one month before the current date:

DateAdd ("m", -1, CurrentDate)

But now I need to make the -1 dynamic. Something along the lines of DateAdd ("m", {?Custom_From_Date}, CurrentDate)

The custom parameter will have numbers for months to be chosen. How can I accomplish this?


Solution

  • Then in this case you need to use this formula in record selection formula like below.

    First you need create a format like on you mentioned {?Custom_From_Date} and should ask user that enter a value with - if before current date and with + if after current date.

    If your database date format is date then use like below in record selection formula

    Database.datefield >=CDate(DateAdd ("m", {?Custom_From_Date}, CurrentDate))
    

    if your database date format is datetime then use like below in record selection formula:

    Database.datefield >=DateAdd ("m", {?Custom_From_Date}, CurrentDate)