Subtraction of dates

FPocoFPoco Member Posts: 35
Hello

How can I make a subtraction of a date for a filter. I try to make at CALCDATE but not withdraw the expected result

Thanks

Comments

  • SavatageSavatage Member Posts: 7,142
    How do you want this to work??

    # of days = date1 - date 2
  • FPocoFPoco Member Posts: 35
    I do a filter data by the customer, then I would subtract one year from this filter, to be able to sort a column by the filter of the map and the other column for the result of subtraction of dates
  • NaviDevNaviDev Member Posts: 365
    CALCDATE should work fine for your scenario.
    YourFilteringDate := TODAY;
    ExpectedResultDate := CALCDATE('-1Y', YourFilteringDate);
    MESSAGE('%1', ExpectedResultDate);
    
    Navision noob....
  • FPocoFPoco Member Posts: 35
    This works but what I needed even now was to use the filter that I use in the report and then make calcdate
  • SavatageSavatage Member Posts: 7,142
    did you try changing TODAY to your date variable?
  • krikikriki Member, Moderator Posts: 9,110
    NaviDev wrote:
    CALCDATE should work fine for your scenario.
    YourFilteringDate := TODAY;
    ExpectedResultDate := CALCDATE('-1Y', YourFilteringDate);
    MESSAGE('%1', ExpectedResultDate);
    
    You should use : CALCDATE('<-1Y>', YourFilteringDate);
    Otherwise if you work in another language, it might be that 'Y' has no sense and thus gives an error.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • CobblerCobbler Member Posts: 16
    Hello,

    I've a similar problem.
    A table has a starter and an ending date.
    I need to insert a new column to calculate the remaining days. So the task sounds very simply, but when I saw the CALCDATE in the Help I said myself: oh my God... what a difficult it is.

    Can anyone help me in this?
    I would need the formula that operates the substraction.
  • CobblerCobbler Member Posts: 16
    Hm...

    I played a little with the fields.
    I created an Integer variable in the C/AL Globals.
    Then I typed this: newdate := endingDate - startingDate;

    And it seems it works. I get the result of the substraction in days :)
  • krikikriki Member, Moderator Posts: 9,110
    Cobbler wrote:
    Hm...

    I played a little with the fields.
    I created an Integer variable in the C/AL Globals.
    Then I typed this: newdate := endingDate - startingDate;

    And it seems it works. I get the result of the substraction in days :)
    =D> That's the correct way.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.