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 date fields?

Former Member
0 Likes
7,696

Hi SDN,

I have to date fields lv_d1 & lv_d2 i want to find out the comparision or difference between the above two fields.

regards,

Rahul

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,062

u havnt specified ..u want 2 compare 2 dates on wat basis..

den also use this FM HR_99S_INTERVAL_BETWEEN_DATES

to get da difference between 2 dates in days ,weeks and months...

let me knw if it is smthin else

Hope dis helps..

Reward if it does

9 REPLIES 9
Read only

Former Member
0 Likes
2,062

hi

rahul,

data:

lv_int1 type i,

lv_int2 type i.

lv_int1 = lv_d1.

lv_int2 = lv_d2.

lv_int2 = lv_int2 - lv_int1.

wht evere comparision u want u can do basically wht happns is int variables will have the value of no of days so u can compare wht ever u want

plzz reward if u found my answer helpfull to u

Read only

Former Member
0 Likes
2,062

Hi,

1. Difference:

lv_dt2 - lv_dt1 = <Number of days>

2. Comparison:

if lv_dt2 > lv_dt1 .

....lv_dt2 is latest date menas the condition will be true......

endif.

- Selva

Read only

Former Member
0 Likes
2,062

hi,

use this fm /SDF/CMO_DATETIME_DIFFERENCE.

it will solve ur problem.

Reward points if helpful,

Regards,

Sumanjeet.

Read only

0 Likes
2,062

Thanks for reply,

but i want the difference between 2 days should be greater than equal to 6 months.

how can i get the difference between two dates in months.

Regards,

Rahul

Read only

0 Likes
2,062

Hi,

Use the FM HR_HK_DIFF_BT_2_DATES. In oputput format put value as 04.

Thanks,

Lalit

Read only

0 Likes
2,062

Hi Rahul,

Try any one of this function modules.

HRVE_GET_TIME_BETWEEN_DATES

CX_SCHED_VIA_OPERATING_TIME

SD_DATETIME_DIFFERENCE

SD_CALC_DURATION_FROM_DATETIME

HR_HK_DIFF_BT_2_DATES

Pllzzz Reward if useful,

Mahi.

Read only

0 Likes
2,062

Hi Rahul,

You can directly compare the 2 date fields.

eg... if di > d2.

else.

lv_diff = d2 - d1. You will get the value in no. of Days. You can divide this value by 30 to get the no. of months.

Lokesh

Read only

Former Member
0 Likes
2,063

u havnt specified ..u want 2 compare 2 dates on wat basis..

den also use this FM HR_99S_INTERVAL_BETWEEN_DATES

to get da difference between 2 dates in days ,weeks and months...

let me knw if it is smthin else

Hope dis helps..

Reward if it does

Read only

Former Member
0 Likes
2,062

hi,

you can use FIMA_DAYS_AND_MONTHS_AND_YEARS

Get number of days. Year, Months between two dates.

regards,

pavan