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: 
Read only

Count weeks between 2 dates

Former Member
0 Likes
2,968

Hi all

is there a FM to count weeks between 2 dates? For ex. I should have know how many weeks are between 10-November 2008 and 20-Februara 2009.

Thank you

Herbert

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,939

HR_99S_INTERVAL_BETWEEN_DATES: Difference between two dates in days, weeks, months

9 REPLIES 9
Read only

Former Member
0 Likes
1,939

check this fm

HR_IE_NUM_PRSI_WEEKS

Return the number of weeks between two dates.

Read only

Former Member
0 Likes
1,939

Hi.

U try this function module...

DATE_GET_WEEK

Regards:

Prabu

Read only

bpawanchand
Active Contributor
0 Likes
1,939

Hi

Check this snippet

DATA :
  w_d1 TYPE sy-datum,
  w_d2 TYPE sy-datum,
  w_temp TYPE i,
  w_week TYPE i..

w_d1 = '20080801'.
w_d2 = sy-datum.
w_temp = w_d2 - w_d1.

w_week  = w_temp DIV 7.

WRITE :
  / w_week.

Regards

Pavan

Read only

former_member585060
Active Contributor
0 Likes
1,939

Try this FM 'ISP_COUNT_WEEKS_ROUND_DOWN'

Read only

Former Member
0 Likes
1,940

HR_99S_INTERVAL_BETWEEN_DATES: Difference between two dates in days, weeks, months

Read only

Former Member
0 Likes
1,939

Hi,

Check this FM,

HR_99S_INTERVAL_BETWEEN_DATES

Regards

Adil

Read only

Former Member
0 Likes
1,939

Hi,

We can use "HR_99S_INTERVAL_BETWEEN_DATES" function module.

hope this helps.

thanx,

dhanashri.

Read only

Former Member
0 Likes
1,939

HI herbert,

you can calculate the weeks in ayear by the following formula.

first calculate the no of days between two dates.

then apply

data: no_w type i,

no_d type i.

no_d = no_d / 7.

best wishes

prasad

Read only

Former Member
0 Likes
1,939

Hi,

please go through following piece of code this will help u...

*10-November 2008 and 20-Februara 2009

data: dat1 type PC26W-WEEKS.

data: p_beg type sy-datum.

data: p_end type sy-datum.

data: t_beg type sy-datum.

t_beg = '20080303'.

p_beg = '20081110'.

p_end = '20090220'.

CALL FUNCTION 'HR_IE_NUM_PRSI_WEEKS'

EXPORTING

TAX_YEAR_BEGIN = t_beg

PERIOD_BEGIN = p_beg

PERIOD_END = p_end

IMPORTING

NUM_WEEKS = dat1

  • EXCEPTIONS

  • END_LT_START = 1

  • END_LT_YEAR_START = 2

  • START_LT_YEAR_START = 3

  • OTHERS = 4

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

write:dat1.

Thanks & Regards

Ashu Singh