SAP CHAR DATE TIME FIELDS NUMLIKE
Get Example source ABAP code based on a different SAP table
ARTICLE
Accessing Character-Like Date Fields and Time Fields Numerically
Numeric access to character-like date fields and time fields exploits the fact that the
Example
The following calculations provide the current day of the year, plus the hour, minutes, and seconds of the current time. The date and time are provided by a
time TYPE t,
time_stamp TYPE timestamp,
day TYPE i,
hour TYPE i,
minute TYPE i,
second TYPE i,
first_day TYPE d.
GET TIME STAMP FIELD time_stamp.
CONVERT TIME STAMP time_stamp TIME ZONE sy-zonlo
INTO DATE date TIME time.
first_day = date(4) <(> <)><(> <)> '0101'.
day = date - first_day + 1.
second = ( time - t`000000` ).
hour = second DIV 3600.
second = second - hour * 3600.
minute = second DIV 60.
second = second - minute * 60.
Example
The following calculation produces the day of the week for a date field
Example
The following calculations provides the last day of the previous month.
date = sy-datlo.
date+6(2) = '01'.
date = date - 1.