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

Date comparisions

Former Member
0 Likes
517

Hi,

I am having 2 dates in the format YYYYMMDD. How can i compare both the dates. The date1 should be less than date2. Can u tell the FM to compare the dates. Urgent.

Thanks.

4 REPLIES 4
Read only

Former Member
0 Likes
491

Hi,

Check this sample..

DATA: V_DATE1 TYPE SYDATUM.

DATA: V_DATE2 TYPE SYDATUM.

    • the internal date format is YYYYMMDD..which is of type D.

V_DATE1 = SY-DATUM.

V_DATE2 = SY-DATUM - 1.

  • Comparison

IF V_DATE1 < V_DATE2.

WRITE: / 'V_DATE1 IS LESSER'.

ELSE.

WRITE: / 'V_DATE2 IS LESSER'.

ENDIF.

Thanks,

Naren

Read only

0 Likes
491

data: date1 type d value '20060101',

date2 type d value '20060102'.

if date1 LT date2.

write date1.

else.

write date2.

endif.

Read only

Former Member
0 Likes
491

Naren's example is simple and best suitable.

Just incase you need a FM: <b>FIMA_DATE_COMPARE</b> can help you.

Just the dates input is enough. It gives if first date is LT or EQ or GT second date...

Regards

Eswar

Read only

Former Member
0 Likes
491

Hi

use this FM

<b>C14B_DATE_TIME_COMPARE</b>

enter the dates and it will generate a flag = 'X' if the first date is less than second

Hope this will help you a lot

Thanks

Shiva