ABAP Substract 2 timestamps

A Google search turns up this recommendation: http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/840ad679-0601-0010-cd8e-9989fd650822#q-8: use the class CL_ABAP_TSTMP. You can also see an example of how to use the class in this thread: http://scn.sap.com/thread/85476.

 cl_abap_tstmp=>systemtstmp_syst2utc(
    exporting
      syst_date = <wa_joblist>-strtdate
      syst_time = <wa_joblist>-strttime
    importing
      utc_tstmp = start_stamp ).

  cl_abap_tstmp=>systemtstmp_syst2utc(
    exporting
      syst_date = sy-datum
      syst_time = sy-uzeit
    importing
      utc_tstmp = now_stamp ).

  seconds = cl_abap_tstmp=>subtract(
      tstmp1 = now_stamp
      tstmp2 = start_stamp ).
See also: http://stackoverflow.com/questions/10539133/difference-between-2-timestamps

Leave a Reply