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

function between 2 dates

Former Member
0 Likes
980

i have 2 dates from table "date1" "date2".

i want that date3 will get the biggest date between the two, and if both of them are null he will get a value

that i tell him.

10 REPLIES 10
Read only

Former Member
0 Likes
954
if date1 is initial and 
   date2 is initial.
*-- set default value
   date3 = <default value>.
elseif date1 > date2.
  date3 = date1
else.
  date3 = date2.
endif.
Read only

0 Likes
954

i'm looking for function

thanks

Read only

0 Likes
954

> i'm looking for function

> thanks

I don't think there is any function module to do that.

Read only

0 Likes
954

There is no existing FM to do this. Its a simple comparision that it does not warrant a seperate Funtion module. But if you need one, you can always create a new function module and put in Srinivas's or Vijay's code in it.

Read only

0 Likes
954

If you prefer to have a function, you can use the code provided above and create your own function module.

Regards,

Rich Heilman

Read only

0 Likes
954

I would go on with Srinivas this is to "simple" to capture it in a function...

and the issue was "biggest date between" thats why I used -1 to get the day before...

Read only

Former Member
0 Likes
954

Hi,

if not date1 is initial and

not date2 is initial.

if date1 gt date2

date3 = date1 - 1.

else.

date3 = date2 - 1.

endif.

else.

  • tell me something for date3

endif.

regards matt

Read only

Former Member
0 Likes
954

Hi,

data: date1 type sy-datum,

date2 type sy-datum,

date3 type sy-datum.

date1 = sy-datum.

date2 = sy-datum + 1.

if date1 gt date2.

date3 = date1 .

else.

date3 = date2 .

endif.

Regards

vijay

Read only

Former Member
0 Likes
954

By comparing both dates you can get which is bigger.

Read only

Former Member
0 Likes
954

If you are looking for a Fuction Module, try RELATION_BETWEEN_TWO_DATES