Application Development 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: 

how to calcutae week using date..?

Former Member
0 Kudos

hi ,

can any one tell me how to calcutae week no using date..? pls provide some sample code.can i use WEEKNR_GET.

point wil be rewarded

ravi

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Ravi,

USe FM :

<b>GET_WEEK_INFO_BASED_ON_DATE

DATE_GET_WEEK</b>

Regards points if helpful.

Regards,

Hemant

6 REPLIES 6

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please use this FM.

DATE_GET_WEEK

GET_WEEK_INFO_BASED_ON_DATE


PARAMETERS: P_DATE LIKE SCAL-DATE DEFAULT SY-DATUM.
                
DATA: WA_WEEK LIKE SCAL-WEEK.
                                     
CALL FUNCTION 'DATE_GET_WEEK'
  EXPORTING
    DATE         = P_DATE
  IMPORTING
    WEEK         = WA_WEEK
  EXCEPTIONS
    DATE_INVALID = 1
    OTHERS       = 2.

WRITE: / 'Week no. is ', WA_WEEK+4(2).

Regards,

Ferry Lianto

Former Member
0 Kudos
Data : datum like prowf-ertag,
DATA: week LIKE scal-week.

CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = datum
IMPORTING
week = week
EXCEPTIONS
date_invalid = 1
OTHERS = 2.

write : week.

Former Member
0 Kudos

I would suggest using function module GET_WEEK_INFO_BASED_ON_DATE. You just place a call in your code like this:

DATA: w_date TYPE sy-datum,

w_week TYPE scal-week,

w_monday TYPE sy-datum,

w_sunday TYPE sy-datum.

CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'

EXPORTING

date = w_date

IMPORTING

week = w_week

monday = w_monday

sunday = w_sunday.

I hope this helps.

- April King

sreeramkumar_madisetty
Active Contributor
0 Kudos

Hi

Use the FM:

'GET_WEEK_INFO_BASED_ON_DATE'

Regards,

Sreeram

Former Member
0 Kudos

Hi Ravi,

USe FM :

<b>GET_WEEK_INFO_BASED_ON_DATE

DATE_GET_WEEK</b>

Regards points if helpful.

Regards,

Hemant

Former Member
0 Kudos

Hi Ravi,

To calculate week from date you can use this function HRIQ_DATE_GET_WEEK

It´s an example:

REPORT ZPRUEBA2.

DATA v_getweek TYPE SCAL-WEEK.

DATA v_week(2) TYPE C.

CALL FUNCTION 'HRIQ_DATE_GET_WEEK'

EXPORTING

date = SY-DATUM

IMPORTING

WEEK = v_getweek

EXCEPTIONS

DATE_INVALID = 1

OTHERS = 2.

IF sy-subrc EQ 0.

v_week = v_getweek+4(2).

WRITE v_week.

ENDIF.