Add time to a date and time using FM C14B_ADD_TIME

Author | Last Updated| | 0 Comments Facebook Share Twitter Share Google Plus Share A+ A-


Adding time to a date and time to determine new date time using function module C14B_ADD_TIME

When developing a SAP ABAP report based on date calculations, we may need to add time to a date and do some reporting, in the below tutorial, we will be learning how to add time to a date.

FUNCTION MODULE: C14B_ADD_TIME

When using below FM we need to pass start date (what is the start date), start time (what is start time) and add time (time to be added), below is the example program.

REPORT zadd_date_time.

DATA: lv_newdate TYPE d.
DATA: lv_newtime TYPE t.

PARAMETERS: p_ntime TYPE t.  "Time to be added
PARAMETERS: p_sdate TYPE d. "Start Date
PARAMETERS: p_stime TYPE t. "Start Time

START-OF-SELECTION.

  CALL FUNCTION 'C14B_ADD_TIME'
    EXPORTING
      i_starttime = p_stime
      i_startdate = p_sdate
      i_addtime   = p_ntime
    IMPORTING
      e_endtime   = lv_newtime
      e_enddate   = lv_newdate.

  WRITE:/ 'Added Date and Time are:'.
  WRITE:/ 'DATE:', lv_newdate.
  WRITE:/ 'TIME:', lv_newtime.

Example 1: With the above program we will be adding time example 13 hours to today date and current time.

add time to date SAP ABAP

add time to date SAP ABAP

Tutorial Comments

Total Comments: Add your Comment

Leave a Comment

Enter Comment Text