Ansicht
Dokumentation

ABENSQL_TIME_FUNC - SQL TIME FUNC

ABENSQL_TIME_FUNC - SQL TIME FUNC

PERFORM Short Reference   General Material Data  
This documentation is copyright by SAP AG.
SAP E-Book

- Time Functions

Generic time functions

1. ... IS_VALID( date$|time$|utclong )
    $| EXTRACT_HOUR( time$|utclong )
    $| EXTRACT_MINUTE( time$|utclong )
    $| EXTRACT_SECOND( time$|utclong ) ...


Functions for TIMS

2. ... TIMS_IS_VALID( time ) ...



Effect

These SQL functions perform operations on times with arguments of the built-in data types DATN, DATS, TIMN, TIMS, and UTCLONG. The first set covers generic functions and the second set covers a function depending on the data type TIMS. 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 specified as actual parameters. If an actual parameter contains the null value, every function except IS_VALID and TIMS_IS_VALID returns a null value.

Generic Time Functions

... IS_VALID( date$|time$|utclong )
  $| EXTRACT_HOUR( time$|utclong )
  $| EXTRACT_MINUTE( time$|utclong )
  $| EXTRACT_SECOND( time$|utclong ) ...


Variants:

1. ... IS_VALID( date$|time$|utclong ) ...

2. ... EXTRACT_HOUR( time$|utclong ) ...

3. ... EXTRACT_MINUTE( time$|utclong ) ...

4. ... EXTRACT_SECOND( time$|utclong ) ...

Effect

These SQL functions perform operations with arguments of the built-in data types DATN, DATS, TIMN, TIMS, and UTCLONG.

Note

All generic functions enforce strict mode from Release .

Variant 1

... IS_VALID( date$|time$|utclong ) ...


Effect

The generic function IS_VALID determines whether

  • the specification date contains a valid date in the format YYYYMMDD. The actual parameter must have the built-in data type DATN or DATS.
  • the specification time contains a valid time in the format HHMMSS. The actual parameter must have the built-in data type TIMN or TIMS.
  • the specification utclong contains a valid time stamp in a format like 0001-01-01T00:00:00.0000000. The actual parameter must have the built-in data type UTCLONG.

The result has the data type INT4. A valid time and the empty value (for the data types TIMN and TIMS) produce the value 1 and all other input values (including the null value) produce the value 0.

Note

The generic function IS_VALID applies to date functions and time stamp functions as well.

Example

Applying the generic function to a time column of the DDIC database table DEMO_EXPRESSIONS.



Variant 2

... EXTRACT_HOUR( time$|utclong ) ...


Effect

The generic function EXTRACT_HOUR extracts the hour of a time or a time stamp. The actual parameter must have the built-in data type TIMN, TIMS, or UTCLONG.

The result of the function EXTRACT_HOUR has the data type INT4. The function returns the value 0 for initial input values. If no valid time is passed as a TIMS value, the function EXTRACT_HOUR raises a catchable exception of class CX_SY_OPEN_SQL_DB.

Notes

  • If the built-in data type TIMN or UTCLONG is used, the function EXTRACT_HOUR calls the HANA function EXTRACT.
  • If the built-in data type TIMS is used, the function EXTRACT_HOUR internally uses the ABAP SQL SUBSTRING function and a CAST expression afterwards. The corresponding rules apply.

Variant 3

... EXTRACT_MINUTE( time$|utclong ) ...


Effect

The generic function EXTRACT_MINUTE extracts the minute of a time or a time stamp. The actual parameter must have the built-in data type TIMN, TIMS, or UTCLONG.

The result of the function EXTRACT_MINUTE has the data type INT4. The function returns the value 0 for initial input values. If no valid time is passed as a TIMS value, the function EXTRACT_MINUTE raises a catchable exception of class CX_SY_OPEN_SQL_DB.

Notes

  • If the built-in data type TIMN or UTCLONG is used, the function EXTRACT_MINUTE calls the HANA function EXTRACT.
  • If the built-in data type TIMS is used, the function EXTRACT_MINUTE internally uses the ABAP SQL SUBSTRING function and a CAST expression afterwards. The corresponding rules apply.

Variant 4

... EXTRACT_SECOND( time$|utclong ) ...


Effect

The generic function EXTRACT_SECOND extracts the second of a time or a time stamp. The actual parameter must have the built-in data type TIMN, TIMS, or UTCLONG.

The result of the function EXTRACT_SECOND has the data type INT4. The function returns the value 0 for initial input values. If no valid time is passed as a TIMS value, the function EXTRACT_SECOND raises a catchable exception of class CX_SY_OPEN_SQL_DB.

Notes

  • If the built-in data type TIMN or UTCLONG is used, the function EXTRACT_SECOND calls the HANA function EXTRACT.
  • If the built-in data type TIMS is used, the function EXTRACT_SECOND internally uses the ABAP SQL SUBSTRING function and a CAST expression afterwards. The corresponding rules apply.

Example

Applying the generic functions to time and time stamp columns of the DDIC database table DEMO_EXPRESSIONS.



Functions for TIMS

... TIMS_IS_VALID( time ) ...

Variants:

1. ... TIMS_IS_VALID( time )

Effect

These SQL functions perform operations with arguments of the built-in data type TIMS.

Variant 1

... TIMS_IS_VALID( time )


Effect

The function TIMS_IS_VALID determines whether the specification time contains a valid time in the format HHMMSS. The actual parameter must have the built-in data type TIMS. The result has the data type INT4. A valid time and the empty value produce the value 1 and all other input values (including the null value) produce the value 0.

Note

The use of this function requires the strict mode from Release .

Example

Applying the time function to a time column of the DDIC database table DEMO_EXPRESSIONS. The program DEMO_SQL_TIME_FUNCTIONS executes this access to the table and represents the result.






Addresses (Business Address Services)   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 13460 Date: 20240420 Time: 143831     sap01-206 ( 201 ms )