Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Date determination

alex_georgek
Associate
Associate
0 Kudos
189

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

1 ACCEPTED SOLUTION

Ruediger_Plantiko
Active Contributor
0 Kudos
157

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.

2 REPLIES 2

Ruediger_Plantiko
Active Contributor
0 Kudos
158

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.

kakshat
Product and Topic Expert
Product and Topic Expert
0 Kudos
157

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?