How to get day number from date in abap?
3 answers
It is absolutely not necessary to rely on any functional module that may or may not be on your system. Just use the basic built-in language elements:
DATA: l_my_date TYPE d, " note that the data type D is YYYYMMDD
l_jan_01 TYPE d, " This will be jan 1 of the needed year
l_day TYPE i.
l_my_date = ...whatever...
l_jan_01 = l_my_date.
l_jan_01+4 = '0101'. " or any other means to get the first day of the year.
l_day = l_my_date - l_jan_01 + 1.
+3
source to share
You can use this function module: HR_AUPBS_MONTH_DAY
.
You need to pass in a start date and an end date and it will return the number of days in between (which is what you want):
CALL FUNCTION 'HR_AUPBS_MONTH_DAY'
EXPORTING BEG_DA = P_BEGDA " Here you should put the first day of the year
END_DA = P_ENDDA " Here you put the date
IMPORTING NO_CAL_DAY = P_CAL_DAY. " This is what you want
+2
source to share