Calculate Date based on Period.

HuvanHuvan Member Posts: 3
Hi
I need to calcualte compensation based on the date specified and i have a setup table where i will give settign calcualtion for compensation (Like if a person has been set a option of week ( Compensation calcualted based on weeks). and period is 2( 2 Week means that the compensation is calculated per 2 two weeks.)

I have a table where in i create records for all the calcualted Compensation so that its not Imported again.
My problem is how to calculate the date (for every two weeks if i give a filter of date 010510 to 31 05 10).
(*,)

I should calcualte it for all the resource that are applicable for this time period, each person have a different Calculation (week, quarter,month).

Regards
Huvan ]

Comments

  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Is it a question? Wrong forum?

    If I understand correctly you want to calculate a date that is two weeks ahead from a given date. Take a look at the function CALCDATE.
    NewDate := CALCDATE('<+2W>',GivenDate); // 2 weeks
    NewDate := CALCDATE('<+1M>',GivenDate); // 1 month
    NewDate := CALCDATE('<+1Q>',GivenDate); // 1 quarter
    
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • HuvanHuvan Member Posts: 3
    Hi,

    I too know how to work on calcdates.
    But my question is
    how to calculte in a loop for a given set of date(say for 030510..300510).
    which have 4 weeks the user has an option of 2 weeks(every two weeks i have to calcualte compensation this should be calculted only twice).
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    If you know about CALCDATE you should also know that the Expression of CALCADATE is a string. You could substitute it by STRSUBSTNO.
    NewDate := CALCDATE(STRSUBSTNO('<+%1W>',NoOfWeeks),GivenDate);
    

    And you can subtract GETRANGEMAX from GETRANGEMIN of your range to get the number of days between that two dates. Divide it by the length of your period so that you know how many iterations your loop needs.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision Classic Client' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.