
If you want to store date information in a database field, you can choose from two types:
- DATS stores the date as it is processed in ABAP. That means, the date is stored as a character of length 8 in the format 'YYYYMMDD'.
- DATN stores the information in the date type of the database. When reading the information from the database with ABAP SQL, it is automatically converted back to the 8-digits format.
The same difference exists between types TIMS and TIMN.
If you want to store time stamp information in a database field, you can choose from three types:
- TIMESTAMP stores the information as a number without decimals, where the digits of the number represent the year, month, day, hours, minutes, and seconds.
- TIMESTAMPL is the same as TIMESTAMP, but in addition stores up to 7 decimals which corresponds to a precision of 100 nanoseconds.
UTCLONG has the same precision as TIMESTAMPL but stores the information as an integer of 8 byte length.
SQL Functions for Date, Time, and Time Stamp
ABAP SQL offers a huge variety of built-in functions for date, time, and timestamp information. There are functions to check whether the content of a field is valid, functions for calculations, or functions to extract certain information from an input argument. Some of these functions are listed here. A complete list can be found in the ABAP documentation.

Some of the functions are type-specific. The names of these functions start with a prefix that identifies the type they request as input. Functions starting with DATS_ require input of type DATS, functions starting with DATN_ require input of type DATN, and so on.
Other functions are generic. They can handle input of different types. Function IS_VALID, for example, can check the validity of a date, a point in time, or a time stamp. It accepts both date formats (DATS and DATN) and both time formats (TIMS and TIMN). For time stamps, however, only type UTCLONG is supported.
In some cases, you can choose between a type-specific function and a generic function. For a field of type DATS, for example, you can either use DATS_IS_VALID( ) or IS_VALID( ). You should prefer the newer, generic functions.
Note
The generic functions do not support time stamps of type TIMESTAMP and TIMESTAMPL, at present. For these types, you have to use the type-specific functions starting with TSTMP_.
Here is an example of the usage of generic functions with date-like information. Like most other SQL expressions, you can use the functions in the WHERE-clause, too. Here, we restrict the selection to travels that exceed 10 days.
Note
Function IS_VALID( ) is not a real boolean function. It returns integer value 1 for true and 0 for false.