Getting Monday of a particular week

sabzamsabzam Member Posts: 1,149
Dear all,

I need to get the date of a Monday of a particular week. How could I get it from Nav?

Comments

  • kitikkitik Member Posts: 230
    Use the function DWY2DATE.

    From NAV Help:
    DWY2DATE (Date)
    Use this function to return a Date based on a weekday, a week, and a year

    Salut!
    Laura Nicolàs
    Author of the book Implementing Dynamics NAV 2013
    Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.
  • NagiNagi Member Posts: 151
    Perhaps you should have a look at the function CALCDATE. For example CALCDATE('<-CW>',TODAY) would return the date of Monday in the current week. The parameter TODAY can be exchanged with any other date to get the date of Monday in that particular week.
  • lvanvugtlvanvugt Member Posts: 774
    I wonder if both CALCDATE and DWY2DATE would help you if I read
    sabzam wrote:
    ... date of a Monday of a particular week...
    as knowing a week number and wanting to determine the date of the Monday in that week.
    If that's the case I would use the Date table to find out.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • kitikkitik Member Posts: 230
    You can also find it out using the Date table, but it will take longer than using the function.

    Try this
    WeekNo := 4;
    Year := 2010;
    
    VarTime[1] := TIME;
    
    Date2.SETRANGE("Period Type",Date2."Period Type"::Year);
    Date2.SETRANGE(Date2."Period No.",Year);
    Date2.FINDFIRST;
    
    Date.SETRANGE("Period Type",Date."Period Type"::Week);
    Date.SETRANGE("Period Start",Date2."Period Start",Date2."Period End");
    Date.SETRANGE("Period No.",WeekNo);
    Date.FINDFIRST;
    
    ResultDate[1] := Date."Period Start";
    
    VarTime[2] := TIME;
    
    VarTime[3] := TIME;
    ResultDate[2] := DWY2DATE(1,WeekNo,Year);
    VarTime[4] := TIME;
    
    MESSAGE('Date Table    %1    %2\DWY2DATE   %3    %4',
      ResultDate[1], VarTime[2]-VarTime[1],
      ResultDate[2], VarTime[4]-VarTime[3]);
    


    Salut!
    Laura Nicolàs
    Author of the book Implementing Dynamics NAV 2013
    Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.
Sign In or Register to comment.