Getting day of the year from DD/MM/YYYY using function in SAP system


You can do this by following line of code:

DATA(l_day) = m_date - CONV d(m_date(4) && '0101' ) + 1.

Where m date is the date that needs to be input as type d. Note the format of type d is YYYYMMDD.

Example

If the above function is not present in your system, you can use the below code using simple date subtraction.

DATA: l_date TYPE d,
l_jan_01 TYPE d,
l_day TYPE i.
l_date = “your input date in YYYYMMDD format”
l_jan_01 = l_date.
l_jan_01+4 = '0101'. ( sets the date to first day of year)
l_day = l_date - l_jan_01 + 1.

Updated on: 18-Dec-2019

344 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements