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

Comparing two timestamps

Former Member
0 Likes
7,773

How can we compare two time stamps ???

I tried using GE operator but it is not comparing it correctly. It is comparing it in numerical manner.

Please give the appropriate solution .

1 ACCEPTED SOLUTION
Read only

Former Member
3,471

Hi,

Use the COMPARE method in the class CL_ABAP_TSTMP which is the optimal way.

CALL METHOD cl_abap_tstmp=>compare

EXPORTING

tstmp1 = timestamp1

tstmp2 = timestamp2

receiving

comp = result. " Result: Smaller (-1), Equal (0), Greater (1)

Cheers

Kothand

Hi Shreya,

Check out this link, which have comparision an also conversion of timestamps:

http://www.sapnet.ru/abap_docu/ABENTIME-STAMP-GENERAL.htm

Hope this helps you.

Regards,

Chandra Sekhar

5 REPLIES 5
Read only

Former Member
0 Likes
3,471

Hi,

TIMESTAMP is stored in the database in the UTC time zone. Time stamp values in the database are therefore independent of the time zone of the application that generated the value, and independent of the database instance. This means that you can compare time stamp values across different time zones.

TIMESTAMP data is represented as an object by using the class java.sql.Timestamp.

For further details,

check the source link [http://help.sap.com/saphelp_webas630/helpdata/en/6c/7784ac804be2419f957e8434be6a07/content.htm]

regards,

anirban

Read only

Former Member
0 Likes
3,471

Hi Shreya,

Check out this link, which have comparision an also conversion of timestamps:

http://www.sapnet.ru/abap_docu/ABENTIME-STAMP-GENERAL.htm

Hope this helps you.

Regards,

Chandra Sekhar

Read only

Former Member
3,472

Hi,

Use the COMPARE method in the class CL_ABAP_TSTMP which is the optimal way.

CALL METHOD cl_abap_tstmp=>compare

EXPORTING

tstmp1 = timestamp1

tstmp2 = timestamp2

receiving

comp = result. " Result: Smaller (-1), Equal (0), Greater (1)

Cheers

Kothand

Read only

Former Member
0 Likes
3,471

Use the COMPARE method of the class:

CL_ABAP_TSTMP.

TRY.

CALL METHOD cl_abap_tstmp=>compare

EXPORTING

tstmp1 =

tstmp2 =

receiving

comp =

.

CATCH cx_parameter_invalid_type .

CATCH cx_parameter_invalid_range .

ENDTRY.

Regards

Kannaiah

Read only

Former Member
0 Likes
3,471

hi,

You can use CL_ABAP_TSTMP Class for the purpose.

Plz Refer to this link.

http://www.thaiabap.com/index.php?view=article&catid=47%3As&id=2614%3AABENNEWS-620-CLASSES.HTM&optio...

Regards

Sumit Agarwal