CalcDate based on Month (Eg: 08-07 or August 07)

nikeman77nikeman77 Member Posts: 517
I have a posting date filtering set by user.

If user set 01-08-07..3108-07, mine Cust. Ledger Entry.GetFilter("Posting Date") would retrieve value of 08-07 or Aug 07.

Eg: FilterText := Cust. Ledger Entry.GetFilter("Posting Date");

If Evaluate (FilterDate,FilterText) Then; //convert filter text to date format

Now I would like to FilterDate1 := CalcDate('-1Y', FilterDate) ?

It gave me an error:
You cannot base a date calculation on an undefined date.
Date : 0D
Formula: -1Y

Comments

  • dayakardayakar Member Posts: 68
    Try this,
    If Evaluate (FilterDate,FilterText) Then
    FilterDate1 := CalcDate('-1Y', FilterDate)
  • nikeman77nikeman77 Member Posts: 517
    hi dayakar,

    if input for filter text = 08-07 ?
    (Aug 07)

    Does the calcdate works?
  • dayakardayakar Member Posts: 68
    Input for date filter can not be a month only, it will consider the Day of the month also.

    What exactly you want to achieve?
  • nikeman77nikeman77 Member Posts: 517
    Hi dayakar,

    I wanted to put a date range (01-08-07..31-08-07), but I realized while I was testing the output was
    08-07 instead. Not sure if I had key in wrongly.

    Consider that user might be keying it wrongly too.

    JDI
  • dayakardayakar Member Posts: 68
    Hi,

    If user simply enters 08-07 then system will consider as the 08-07-(Current year) i.e 08th day of July .

    It does not mean that Aug'07

    If you want to get the Minimum date and Maximum date entered in the Date filter then use the

    GetRangeMin and GetrangeMAx functions.
  • nikeman77nikeman77 Member Posts: 517
    Hi dayakar,

    Thanks, will do.

    In that case if I need to offset user input date by 1 year I would do as follows:

    StartDate := GetRangeMin(DateFilter); EndDate := GetRangeMax(DateFilter);
    StartDate1 := CalcDate..
Sign In or Register to comment.