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 PROBLEM

Former Member
0 Likes
861

Hi,

I have date format like date-low & date-high in mm/dd/yy.

Now I have to take the difference of both the date.

If the difference is greater that 10 days then i wanted to display an error message.

Now I m putting date like 01/01/2006(date-low) & 01/30/2006(date-high). I stored the difference in local variable but it is negative.

but lv_date is -ve while debugging. How i can convert that one to positive value so that i got my output.

after it i check the coding & wrote the code like

if lv_date gt 10.

message.

endif.

PLZ REPLY ME ASAP.

8 REPLIES 8
Read only

Former Member
0 Likes
795

l_diff = date1 - date2.

l_diff = abs( l_diff ). "to make it positive

if l_diff > 10.

  • Do something

endif.

Read only

Former Member
0 Likes
795

hi Salil,

Vlaidate the value ..

i.e,


if date ge '-10'.
  date = date - date. 
endif.

else ..

date = abs(date).

Regards,

Santosh

Read only

Former Member
0 Likes
795

Do you have the FM 'SD_DATETIME_DIFFERENCE' available. You can use this to return the difference in days. You will have to set the time to be a constant value though.

Read only

Former Member
0 Likes
795

Hello Salil,

U can use SD_DATE_DIFFERENCE Fm and pass date-high to DATE1 and date-low to DATE2.

Read only

Former Member
0 Likes
795

Salil,

subtract from-date from to-date which will give u always +ve value.

-Anu

Read only

Former Member
0 Likes
795

data: l_diff type i.

l_diff = date1 - date2.

l_diff = abs( l_diff ).

if l_diff > 10.

**give error message.

endif.

Ramesh.

Read only

Former Member
0 Likes
795

hi ,

but y will u get the value to negative when

u substract a low date from high date ..

even in selection screen if u refer to the date field it will not accept .

data :   DATE1 LIKE  P0001-BEGDA,
               DATE2 LIKE  P0001-BEGDA.
   data diff type i.
        date1 = '20060130'.
        date2 = '20060101'.

     diff = date1 - date2.

     write:/ diff.

no way im getting a negative value..

i hope u have to substract low date from high date ..

u might be substracting high date from low date ..

data : DATE1 LIKE P0001-BEGDA,

DATE2 LIKE P0001-BEGDA.

data diff type i.

date1 = '20060130'.

date2 = '20060101'.

diff = date2 - date1.

write:/ diff." now here diff is negative ..

pass ur selection screen field data and the lv_date calculation ..in case u r not able to solve ..

regards,

Vij

Message was edited by:

vijay k

Message was edited by:

vijay k

Read only

Former Member
0 Likes
795

Hi salil singh,

I am Ravi. when coming to ur problem of converting a -ve num to a +ve num i give the following code.

lv_date = ABS( lv_date ).

if lv_date gt 10.

write : / message.

endif.

I think this hould solve ur problem.

If u find it useful dont forget to awar me some points.

bye,

Ravi Kumar G.