Convert date to external format

Convert date to external format

Convert date to default external format :


DATA : lw_date_ext TYPE char10,
       lw_date TYPE datum. 
WRITE lw_date TO lw_date_ext.

Other way to do that since 7.40 :


DATA lv_date TYPE d value '20190718'.
DATA(l_user_format) = |{ lv_date DATE = USER }|. "RAW, ISO, USER, ENVIRONMENT
WRITE l_user_format.

Convert date to specified external format :


DATA : lw_date_ext TYPE char10,
       lw_date     TYPE datum.

  CALL FUNCTION 'SLS_MISC_CONVERT_TO_DATE'
    EXPORTING
      p_date        = lw_date
      p_date_format = 'DD.MM.YYYY'
    IMPORTING
      p_date_string = lw_date_ext.

See also Convert date to internal format.

About the author

fjourneau administrator

Hi, I'm Florian Journeau, SAP ABAP R3 Freelance, based in Toulouse, France. You want to know more about me, have a look on my CV : cv.fjourneau.net.

Leave a Reply