What does it do? These SQL functions perform operations on dates with arguments of the built-in data types DATN>>, DATS>>, TIMN>>, TIMS>>, and UTCLONG>>. The first set covers generic functions, the second set covers a function depending on the data type DATN >>, and the third set covers a function depending on the data type DATS>>. The arguments of the functions are specified as a comma-separated list in parentheses. A blank must be placed after the opening parenthesis and in front of the closing parenthesis. SQL expressions > of matching data types can be passed as actual parameters. If an actual parameter contains the null value>, every function except IS_VALID> and DATS_IS_VALID> returns a null value.
What does it do? The generic function IS_VALID> determines whether the specification date>, time>, or utclong> has a valid format. For more information about the IS_VALID> function, see time functions>.
Latest notes: The generic function IS_VALID> applies to time functions> and time stamp functions > as well. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Applying the generic function to a date column of the DDIC database table DEMO_EXPRESSIONS>>. ABEXA 01661 ABAP_EXAMPLE_END
What does it do? The generic function EXTRACT_YEAR> extracts the year of a date or a time stamp. The actual parameter must have the built-in data type DATN>>, DATS>>, or UTCLONG>>. The result of the function EXTRACT_YEAR> has the data type INT4>>. The function returns the value 1 for initial input values. If no valid date is passed as a DATS> value, the function EXTRACT_YEAR> raises a catchable exception of class CX_SY_OPEN_SQL_DB>>.
Latest notes:
If the built-in data type DATN>> or UTCLONG>> is used, the function EXTRACT_YEAR> calls the HANA function EXTRACT>>.
If the built-in data type DATS>> is used, the function EXTRACT_YEAR> internally uses the ABAP SQL SUBSTRING>> function and a CAST>> expression afterwards. The corresponding rules apply. NON_V5_HINTS ABAP_HINT_END
What does it do? The generic function EXTRACT_MONTH> extracts the month of a date or a time stamp. The actual parameter must have the built-in data type DATN>>, DATS>>, or UTCLONG>>. The result of the function EXTRACT_MONTH> has the data type INT4>>. The function returns the value 1 for initial input values. If no valid date is passed as a DATS> value, the function EXTRACT_MONTH> raises a catchable exception of class CX_SY_OPEN_SQL_DB>>.
Latest notes:
If the built-in data type DATN>> or UTCLONG>> is used, the function EXTRACT_MONTH> calls the HANA function EXTRACT>>.
If the built-in data type DATS>> is used, the function EXTRACT_MONTH> internally uses the ABAP SQL SUBSTRING >> function and a CAST>> expression afterwards. The corresponding rules apply. NON_V5_HINTS ABAP_HINT_END
What does it do? The generic function EXTRACT_DAY> extracts the day of a date or a time stamp. The actual parameter must have the built-in data type DATN>>, DATS>>, or UTCLONG>>. The result of the function EXTRACT_DAY> has the data type INT4>>. The function returns the value 1 for initial input values. If no valid date is passed as a DATS> value, the function EXTRACT_DAY> raises a catchable exception of class CX_SY_OPEN_SQL_DB>>.
Latest notes:
If the built-in data type DATN>> or UTCLONG>> is used, the function EXTRACT_DAY> calls the HANA function EXTRACT>>.
If the built-in data type DATS>> is used, the function EXTRACT_DAY> internally uses the ABAP SQL SUBSTRING >> function and a CAST>> expression afterwards. The corresponding rules apply. NON_V5_HINTS ABAP_HINT_END
ABAP_VARIANT_5 ... DAYNAME( date$|utclong ) ...>
What does it do? The generic function DAYNAME> returns the name of a day of a date or a time stamp in uppercase letters in English. The actual parameter must have the built-in data type DATN> >, DATS>>, or UTCLONG>>. The result of the function DAYNAME> has the data type CHAR>> with length 9. If no valid date is saved in a DATS> value, the function DAYNAME> raises a catchable exception of class CX_SY_OPEN_SQL_DB>>.
What does it do? The generic function MONTHNAME> returns the name of a month of a date or a time stamp in uppercase letters in English. The actual parameter must have the built-in data type DATN> >, DATS>>, or UTCLONG>>. The result of the function MONTHNAME> has the data type CHAR>> with length 9. If no valid date is saved in a DATS> value, the function MONTHNAME > raises a catchable exception of class CX_SY_OPEN_SQL_DB>>.
ABAP_VARIANT_7 ... WEEKDAY( date$|utclong ) ...>
What does it do? The generic function WEEKDAY> returns the number of a weekday of a date or a time stamp from 0 to 6. The actual parameter must have the built-in data type DATN>>, DATS>>, or UTCLONG>>. The result of the function WEEKDAY> has the data type INT4>>. If no valid date is saved in a DATS> value, the function WEEKDAY > raises a catchable exception of class CX_SY_OPEN_SQL_DB>>.
What does it do? The function DAYS_BETWEEN> calculates the difference between two dates date1> or utclong1> and date2> or utclong2 > in days. The actual parameters must have the built-in data type DATN>>, DATS>>, or UTCLONG>> and must contain a valid date in the format YYYYMMDD> or a valid time stamp in a format like 0001-01-01T00:00:00.0000000>. Any invalid date is initialized and set to the value 00010101> before the calculation. Any invalid time stamp is initialized and set to the value 0001-01-01T00:00:00.0000000> before the calculation. The result has the data type INT4>>. If date2> is greater than date1>, the result is positive. In the reverse case, it is negative.
Latest notes: It is possible to use two different data types for the function DAYS_BETWEEN> and to calculate the days between these two dates. NON_V5_HINTS ABAP_HINT_END
What does it do? The function ADD_DAYS> adds days> days to a specified date date> or time stamp utclong>.
The actual parameter date> must have the built-in data type DATN>> or DATS>> and must contain a valid date in the format YYYYMMDD>. The actual parameter utclong> must have the built-in data type UTCLONG >> and must contain a valid time stamp in a format like 0001-01-01T00:00:00.0000000>. Any invalid date is initialized and set to the value 00010101> before the calculation and any invalid time stamp is initialized and set to the value 0001-01-01T00:00:00.0000000> before the calculation.
The actual parameter days> must have the built-in data type INT4>>. The result has the data type of the first actual parameter days> or utclong>. If days> is positive, the number of days is added to date> or utclong>. In other cases, the number of days is subtracted. If the calculation produces an invalid date, the function raises a catchable exception of class CX_SY_OPEN_SQL_DB>> if the actual parameter days> is of data type DATN> or UTCLONG>. If the actual parameter days> is of data type DATS>, the function returns the initial date.
What does it do? The function ADD_MONTHS> adds months> months to a specified date date> or time stamp utclong>.
The actual parameter date> must have the built-in data type DATN>> or DATS>> and must contain a valid date in the format YYYYMMDD>. The actual parameter utclong> must have the built-in data type