ian.moree

Why do this calculation for day of week this way?

Discussion created by ian.moree on May 4, 2012
Latest reply on May 4, 2012 by ian.moree

// return the date that is the Monday on or before the first day worked

 

Let (

[

 

first_worked_date = Date ( Month (TimeEntry::timeStart); Day ( TimeEntry::timeStart); Year (TimeEntry::timeStart));

 

// Sunday = 1

 

first_worked_daynum = DayOfWeek ( first_worked_date);

 

// how many days prior is the Monday?

 

offset = Choose ( first_worked_daynum; 0 ; -6; 0 ; -1; -2; -3; -4; -5)

];

 

first_worked_date + offset

)

 

eg / dayofWeek( "5/7/2012" ) = 2 or Tuesday; So

choose above's 2nd result is 0 ? which means we are on the correct day ?

if i continue.

if dayofWeek( "5/8/2012") = 3 0r Wednesday , we are 2 days away from sunday correct?

 

what am i missing here in this calculation PLEASE>.

thanks

 

-ian

Outcomes