How to Calculate ??

navuser1
navuser1 Member Posts: 1,334
Hi All,

Please share your knowledge..........

How to calculate Starting Date & Ending Date from
the Specified(given) Year And Month ?


Like that......

User input

Year := 2008
Month := April

Result (Output)

Startig Date := 01/04/08
Ending Date := 30/04/08
Now or Never

Comments

  • kine
    kine Member Posts: 12,562
    edited 2008-10-01
    You can use the virtual table "Date" to filter for period type Month, filter for all dates from the correct year and filter for the correct month and you will have start and end date.

    Or you can use something like
      StartDate := DMY2DATE(1,MyMonth,MyYear);
      EndDate := CALCDATE('<+CM>',StartDate);
    

    Edit: typing error corrected
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • navuser1
    navuser1 Member Posts: 1,334
    Thnx...Kine !!

    Yes, I have used the Date Table to Solve the issue.
    But Your next Tips is fine...
    Now or Never
  • navuser1
    navuser1 Member Posts: 1,334
    kine wrote:
    You can use the virtual table "Date" to filter for period type Month, filter for all dates from the correct year and filter for the correct month and you will have start and end date.

    Or you can use something like
      StartDate := DMY2DATE(2,MyMonth,MyYear);
      EndDate := CALCDATE('<+CM>',StartDate);
    

    [*]....[*]
    StartDate should be....
      StartDate := DMY2DATE(1,MyMonth,MyYear);
    
    Now or Never
  • garak
    garak Member Posts: 3,263
    Example
    message('Start = %1',format(calcdate('<-CM>',DMY2DATE(23,12,1977))));
    message('END = %1',format(calcdate('<CM>',DMY2DATE(03,12,1977))));
    
    Do you make it right, it works too!
  • navuser1
    navuser1 Member Posts: 1,334
    Great !!
    Now or Never
  • kriki
    kriki Member, Moderator Posts: 9,121
    [Can you change the attribute of the topic to <Solved> (or also <Good Posting>) and remove the text from the title?]
    Please see Forum Rule(s) #3.9: Forum Rules.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!