2013 Jan 26 6:47 AM
Hi Experts,
I have a requirement to calcuate the weeks start date for a particular location say location 1.In this location it is configured that the 1st day for a month starts with Thursday.So based on this i need to calculate the week start date.Say for example
In selection screen i have 3 fields: month week and week start date.My requirement is to calcualte the week start date for a particular location when the user enter month and week.
If current system date is 2012/01/10 (Tuesday) (month 1, week 2) and user inputs month 1, week 3.
If working in location1 (based on configuration for location 1 : start day is Thursday and end date is Wednesday), the first day of working week (week 3) should be Thursday (2012/01/12) .
How to do this technically....
Thanks in advance,
Alex
2013 Jan 26 9:47 AM
Try this (if I understood everything correctly):
form get_first
using
* Weekday with which week starts: 0 = Sunday, 1 = Monday,... :
iv_weekday_week_start type i
* Desired week number 1 = first, 2 = second, ... :
iv_week_number_in_month type i
* Reference Month
iv_ref_month type char02
iv_ref_year type char04
changing
ev_week_start type d.
data: lv_first_of_month type d.
concatenate iv_ref_year iv_ref_month '01' into lv_first_of_month.
ev_week_start =
( iv_weekday_week_start + 1 - lv_first_of_month ) mod 7
+ 7 * ( iv_week_number_in_month - 1 )
+ lv_first_of_month.
endform.
2013 Jan 26 9:47 AM
Try this (if I understood everything correctly):
form get_first
using
* Weekday with which week starts: 0 = Sunday, 1 = Monday,... :
iv_weekday_week_start type i
* Desired week number 1 = first, 2 = second, ... :
iv_week_number_in_month type i
* Reference Month
iv_ref_month type char02
iv_ref_year type char04
changing
ev_week_start type d.
data: lv_first_of_month type d.
concatenate iv_ref_year iv_ref_month '01' into lv_first_of_month.
ev_week_start =
( iv_weekday_week_start + 1 - lv_first_of_month ) mod 7
+ 7 * ( iv_week_number_in_month - 1 )
+ lv_first_of_month.
endform.
2013 Jan 26 3:38 PM
Hi Alex,
I am confused. You say that in your scenario, the first day of the month for a particular location is Thursday. So, shouldn't that mean that Thursday would be the starting day for all working weeks in that month?