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

FM DATE_GET_WEEK giving Error

Former Member
0 Likes
4,726

Dear All,

I'm using the FM DATE_GET_WEEK to convert a Date into a Week.

I gave a Date as 12/28/2008 (MM/DD/YYYY).

The output was 200953.

I think this is absurd. As far as I know there will not be any Calendar week with 53 for the Year 2009.

Is this the Problem with the Fm ?

Is there any SAP note reg. this ?

Request your help !

Thanks & Regards,

Deepu.K

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,053

2009 has 53 weeks, As the first week of a year is the week that contains the first Thursday of a year. In 2009 this is january 1st, in 2010 this will be januaty 7th, so the last week of 2009 will be the 53th. (the week of 2009 begins with 2009.01 monday 12/29/2008 end ends with 2009.53 sunday 01/03/2010, a long year)

(Look at [ISO week date at wikipedia|http://en.wikipedia.org/wiki/ISO_week_date])

Regards

Dear All,

I'm using the FM DATE_GET_WEEK to convert a Date into a Week.

I gave a Date as 12/28/2008 (MM/DD/YYYY).

The output was 200953.

I think this is absurd. As far as I know there will not be any Calendar week with 53 for the Year 2009.

Is this the Problem with the Fm ?

Is there any SAP note reg. this ?

Request your help !

Thanks & Regards,

Deepu.K

15 REPLIES 15
Read only

Former Member
0 Likes
3,053

Hi Deepu,

I have executed the FM by putting the same input 12/28/2008 which you have put. But my output is different that is '200852'.

I Think you might enter some wrong value. I am pretty sure. check it again.

Thanks,

Chidanad

Read only

Former Member
0 Likes
3,053

It is giving correct o/p 200852 if i give date as 28.12.2008 in DATE_GET_WEEK function module

Read only

Former Member
0 Likes
3,053

Indeed is really absurd. But I tried it , gave me 200852. How did you pass the date to the function I passed it as 20081228 ?

regards,

Advait

Read only

0 Likes
3,053

Dear All,

When I pass the Date as 12/28/2008 (MM/DD/YYYY Format) I'm getting the week as 200852.

But when I pass the Date as 12/28/2009 I'm getting the week as 200953.

Regards,

Deepu.k

Read only

rthoodi
Active Participant
0 Likes
3,053

Hello Deepu,

Fm DATE_GET_WEEK works fine

just provide the date as per your sustem default date

my system default date is DD.MM.YYYY

give the date in the same for mat as 13.11.2008

Answer is WEEK : 200846

Thanks

RK

Edited by: RK on Nov 13, 2008 2:20 PM

Read only

Former Member
0 Likes
3,053

Hello RK,

Did u check with MM/DD/YYYY Format and with the Date as 12/28/2009 ?

Let me know what value u r getting for the above params !

Regards,

Deepu.k

.

Read only

Former Member
0 Likes
3,053

Hello,

Year 2009 has 53 weeks. FM is returning the correct values. Have checked the same.

Thanks,

Jayant

Read only

Former Member
0 Likes
3,053

Yes , you are right it does give 200953 for that date. But it is correct. If you notice your outlook calendar , you will see that the week starting from 28th December has week number 53.

regards,

Advait

Read only

rthoodi
Active Participant
0 Likes
3,053

Hello Deepu,

Iam sorry , Iam not able to change my defalut parameters, If I give the date 12/28/2009 , system not accepting and it returns an error message like enter valid value.

For date 28.12.2009 , Iam getting Week 200953.

Thanks

RK

Edited by: RK on Nov 13, 2008 2:40 PM

Read only

0 Likes
3,053

if the date value is in cell B4 of an excell doc

=INT((B4-DATE(YEAR(B4-WEEKDAY(B4-1)4),1,3)WEEKDAY(DATE(YEAR(B4-WEEKDAY(B4-1)4),1,3))5)/7) formula gives the week number.

DATA: date         LIKE scal-date,
      week         LIKE scal-week.
CALL FUNCTION 'DATE_GET_WEEK'
  EXPORTING
    date         = sy-datum
  IMPORTING
    week         = week
  EXCEPTIONS
    date_invalid = 1.
WRITE / week.

output:200846

Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,054

2009 has 53 weeks, As the first week of a year is the week that contains the first Thursday of a year. In 2009 this is january 1st, in 2010 this will be januaty 7th, so the last week of 2009 will be the 53th. (the week of 2009 begins with 2009.01 monday 12/29/2008 end ends with 2009.53 sunday 01/03/2010, a long year)

(Look at [ISO week date at wikipedia|http://en.wikipedia.org/wiki/ISO_week_date])

Regards

Read only

0 Likes
3,053

Hello Raymond,

Thanks for the reply.

Regards,

Deepu.K

Read only

0 Likes
3,053

Hello Deepu,

There were many other correct replies in the thread too... not just 1 (and that too in last).

Thanks,

Jayant

Read only

0 Likes
3,053

Yes Jayanth,

U r right ! But the Reply with reasoning which is suitable for the Queries scenario will be appreiciated !

Anyways ...credit is given

Regards,

Deepu.k

Read only

0 Likes
3,053

Thank you Deepu, We should always be thankful to all the people replying to your post. This should be the best practice to make SDN Best. Thank you for your understanding.

Thanks,

Jayant