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.
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.