Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Timestamp addition

Former Member
0 Likes
1,525

Hi

I have a timestamp value. I want to add 5 and a half hours to this value

Is there any standard function or any way i can do so.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,096

TIMESTAMP_DURATION_ADD

or use the below code

REPORT ZSRK_023 .

DATA : DURATION TYPE F,

UNIT LIKE T006-MSEHI,

END_DATE TYPE SY-DATUM,

END_TIME TYPE SY-UZEIT,

START_DATE TYPE SY-DATUM,

START_TIME TYPE SY-UZEIT,

TIMESTAMP_IN TYPE TIMESTAMP,

TIMESTAMP_OUT TYPE TIMESTAMP,

TIMESTAMP_IN_C(15),

TIMESTAMP_OUT_C(15),

TIMEZONE TYPE TIMEZONE.

  • defaults

IF TIMESTAMP_IN IS INITIAL.

GET TIME STAMP FIELD TIMESTAMP_IN.

ENDIF.

TIMEZONE = 'UTC'.

  • convert to date and time

CONVERT TIME STAMP TIMESTAMP_IN TIME ZONE TIMEZONE

INTO DATE START_DATE TIME START_TIME.

DURATION = 19800 . " 5 1/2 hrs in seconds

UNIT = 'S'.

CALL FUNCTION 'END_TIME_DETERMINE'

EXPORTING

DURATION = DURATION

UNIT = UNIT

  • FACTORY_CALENDAR =

IMPORTING

END_DATE = END_DATE

END_TIME = END_TIME

CHANGING

START_DATE = START_DATE

START_TIME = START_TIME

EXCEPTIONS

FACTORY_CALENDAR_NOT_FOUND = 1

DATE_OUT_OF_CALENDAR_RANGE = 2

DATE_NOT_VALID = 3

UNIT_CONVERSION_ERROR = 4

SI_UNIT_MISSING = 5

PARAMETERS_NO_VALID = 6

OTHERS = 7

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CONVERT DATE END_DATE TIME END_TIME

INTO TIME STAMP TIMESTAMP_OUT TIME ZONE TIMEZONE.

MOVE : TIMESTAMP_IN TO TIMESTAMP_IN_C,

TIMESTAMP_OUT TO TIMESTAMP_OUT_C.

WRITE : / 'Time stamp input' , TIMESTAMP_IN_C,

/ 'Time stamp output' , TIMESTAMP_OUT_C.

Edited by: sreekanth reddy on Nov 3, 2008 4:17 PM

Hi

I have a timestamp value. I want to add 5 and a half hours to this value

Is there any standard function or any way i can do so.

5 REPLIES 5
Read only

Former Member
0 Likes
1,096

FM : EWU_ADD_TIME

Read only

0 Likes
1,096

EWU_ADD_TIME FM not found

Read only

0 Likes
1,096

Its very much there in ecc 6.0 and 4.X series i checked it .

EWU_ADD_TIME . Pls check

Read only

Former Member
0 Likes
1,097

TIMESTAMP_DURATION_ADD

or use the below code

REPORT ZSRK_023 .

DATA : DURATION TYPE F,

UNIT LIKE T006-MSEHI,

END_DATE TYPE SY-DATUM,

END_TIME TYPE SY-UZEIT,

START_DATE TYPE SY-DATUM,

START_TIME TYPE SY-UZEIT,

TIMESTAMP_IN TYPE TIMESTAMP,

TIMESTAMP_OUT TYPE TIMESTAMP,

TIMESTAMP_IN_C(15),

TIMESTAMP_OUT_C(15),

TIMEZONE TYPE TIMEZONE.

  • defaults

IF TIMESTAMP_IN IS INITIAL.

GET TIME STAMP FIELD TIMESTAMP_IN.

ENDIF.

TIMEZONE = 'UTC'.

  • convert to date and time

CONVERT TIME STAMP TIMESTAMP_IN TIME ZONE TIMEZONE

INTO DATE START_DATE TIME START_TIME.

DURATION = 19800 . " 5 1/2 hrs in seconds

UNIT = 'S'.

CALL FUNCTION 'END_TIME_DETERMINE'

EXPORTING

DURATION = DURATION

UNIT = UNIT

  • FACTORY_CALENDAR =

IMPORTING

END_DATE = END_DATE

END_TIME = END_TIME

CHANGING

START_DATE = START_DATE

START_TIME = START_TIME

EXCEPTIONS

FACTORY_CALENDAR_NOT_FOUND = 1

DATE_OUT_OF_CALENDAR_RANGE = 2

DATE_NOT_VALID = 3

UNIT_CONVERSION_ERROR = 4

SI_UNIT_MISSING = 5

PARAMETERS_NO_VALID = 6

OTHERS = 7

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CONVERT DATE END_DATE TIME END_TIME

INTO TIME STAMP TIMESTAMP_OUT TIME ZONE TIMEZONE.

MOVE : TIMESTAMP_IN TO TIMESTAMP_IN_C,

TIMESTAMP_OUT TO TIMESTAMP_OUT_C.

WRITE : / 'Time stamp input' , TIMESTAMP_IN_C,

/ 'Time stamp output' , TIMESTAMP_OUT_C.

Edited by: sreekanth reddy on Nov 3, 2008 4:17 PM

Read only

Former Member
0 Likes
1,096

first convert the time stamp to normal time and date then add 5 and half hours to that time and by using the function module ABI_TIMESTAMP_CONVERT_INTO

it will automatically converts tima and date to timestamp