ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Date and Time Processing → Date Fields and Time Fields
Access to Date Fields and Time Fields
Only a few operand positions are affected by the fact that date fields and time fields contain a local date in the format "yyyymmdd" or a local time in the format "hhmmss":
- When using date fields and time fields as source fields or target fields of a lossless assignment.
- In conversions of a local date and a local time to time stamps using
CONVERT INTO UTCLONG
and back usingCONVERT UTCLONG
.
CONVERT INTO TIME STAMP
and back usingCONVERT TIME STAMP
.
- In output formatting using string templates or the statement
WRITE [TO]
In all other operand positions, the handling of date fields and time fields is specified in the conversion rules and comparison rules for these data types.
- The conversion rules are designed so that data objects of the types
d
andt
display character-like behavior in character-like operand positions and numeric behavior in numeric operand positions. In the latter case, the content of a date field is converted to the number of days since 01.01.0001 and the content of a time field is converted to the number of seconds since midnight.
- The comparison rules are designed so that a later date or later time is greater than an earlier date or earlier time.
Direct assignments or comparisons between the data types d
and t
are meaningless and therefore forbidden. The following sections show examples of how to access date fields and time fields effectively.
Other versions: 7.31 | 7.40 | 7.54
Notes
- The function modules of the function group SCAL provide some additional information about character-like dates, for example the day of the week or the calendar week for a given date.
- Special date functions and time functions can be used in the CDS DDL of the ABAP CDS to edit dates and times saved in database tables.
Example
Conversion of a time stamp to date and time fields and their type-friendly formatting as string templates.
GET TIME STAMP FIELD DATA(ts).
CONVERT TIME STAMP ts TIME ZONE sy-zonlo
INTO DATE DATA(date) TIME DATA(time).
cl_demo_output=>display( |{ date DATE = ISO
}\n{ time TIME = ISO }| ).
Continue
Character-Like Access to Date Fields and Time Fields