SAP CHAR DATE TIME FIELDS ACCESS



Get Example source ABAP code based on a different SAP table
  



Access to Date Fields and Time Fields
Only in a few operand positions is it important 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 using CONVERT UTCLONG.
CONVERT INTO TIME STAMP and back using CONVERT TIME STAMP.
In output formatting using string templates or the statement WRITE $[TO$]
When mapping to asXML or JSON.
In all other operand positions, the handling of date fields and time fields is largely determined by the conversion rules and comparison rules for these data types.
The conversion rules are designed in such a way that data objects of the types d and t behave like character-like objects in character-like operand positions and numerically 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 do not make sense and are therefore forbidden. The following sections show examples of how to access date fields and time fields effectively.
Character-like access to date/time fields
Numeric access to date/time fields



Latest notes:

The function modules of the function pool SCAL provide some additional information about character-like date specifications, 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 process dates and times stored in database tables.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Conversion of a time stamp to date and time fields and their type-friendly formatting using string templates.
ABEXA 00851
ABAP_EXAMPLE_END