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

SAP HANASAPSAP Basis

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.
raja
Published on 16-Dec-2017 00:56:23
Advertisements