Skip to Content
avatar image
Former Member

How does FM DATE_GET_WEEK calculates week number?

Based on research I made to find the standard way to get the week number in SAP, I came up with the conclusion that DATE_GET_WEEK is probably the most common function module used.

Normally, when calculating the week number you should take into account which day decides for the week number. For example, ISO uses Thursday as the week number determinant when it's time to decide for that week which overlaps current and next year.

Other ways use Sunday as determinant. Excel uses something else but has introduced ISO.WEEK.NO in the list of functions.

So my question is how does this function module calculates the week number? Is it based on Sunday, Monday, Thursday? How will it decide the week number for Dec. 31st of 2017? Excel standard WEEK.NO and ISO.WEEK.NO placed it as week #1 of 2018.

I have no mean of testing it right now, And I need to know what would be the standard way of calculating the week number in SAP. So I can make sure all other tools used to query/report data from SAP is using the exact same logic. And we have no intention of building custom functions to accomodate our needs. We want to make sure that we are using what SAP would use if they had to do it.

Thanks in advance!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Dec 29, 2017 at 02:39 PM

    I did not test the FM either, but I used date_get_week as criterion in sap expert notes search app and encountered 810900 - Counting weeks and working days, which explains the approach - first date of the week is always Monday and first week of the year is the one containing January 4th (ISO 8601).

    After reading the note, my understanding is that the same logic for date_get_week is used in F4 date picker in SAP applications, which means that if you have no authorization to execute FMs you can also verify the outcome in other transactions as well (I used VA03):

    Of course, you need to double-check if your applications use the standard approach explained in the note (to be on the safe side, refer to 1063178 - Calendar definition differs from ISO 8601, 1520596 - 0CALWEEK does not support 53 fiscal weeks).

    Add comment
    10|10000 characters needed characters exceeded