SAP Tutorials Blog


 

 


DATA ts_utc TYPE utclong VALUE '2024-11-03 05:30:00'.


CONVERT UTCLONG ts_utc

        INTO DATE DATA(date_utc) "20241103

             TIME DATA(time_utc) "013000

             TIME ZONE 'EST'.


"More optional additions:

"- FRACTIONAL SECONDS: Getting the fractions of seconds

"- DAYLIGHT SAVING TIME: Determining if the time stamp is

"  in a daylight saving time (the example uses time stamp 

"  in August)

CONVERT UTCLONG CONV utclong( '2024-08-08 09:23:11.7681270' )

        INTO DATE date_utc "20240808

             TIME time_utc "052311

             FRACTIONAL SECONDS DATA(fract_sec_utc) "0.768127

             DAYLIGHT SAVING TIME DATA(dsl_utc) "X

             TIME ZONE 'EST'.


"If the time zone specified is initial, there is no conversion.

CONVERT UTCLONG CONV utclong( '2024-08-08 09:23:11.7681270' )

        INTO DATE date_utc "20240808

             TIME time_utc "092311

             TIME ZONE VALUE #( ).


"Specifying a non-existent time zone raises a catchable exception.

TRY.

    CONVERT UTCLONG CONV utclong( '2024-08-08 09:23:11.7681270' )

            INTO DATE date_utc

                 TIME time_utc

                 TIME ZONE 'NOPE'.

  CATCH cx_sy_conversion_no_date_time.

ENDTRY.


Serkan AKKAVAK

Computer Engineer BSc

Head of SAP & Software Department

Contact : serkurumsal@yandex.com