‎2006 Nov 16 8:06 AM
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.
‎2006 Nov 16 8:08 AM
l_diff = date1 - date2.
l_diff = abs( l_diff ). "to make it positive
if l_diff > 10.
Do something
endif.
‎2006 Nov 16 8:09 AM
hi Salil,
Vlaidate the value ..
i.e,
if date ge '-10'.
date = date - date.
endif.else ..
date = abs(date).Regards,
Santosh
‎2006 Nov 16 8:09 AM
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.
‎2006 Nov 16 8:13 AM
Hello Salil,
U can use SD_DATE_DIFFERENCE Fm and pass date-high to DATE1 and date-low to DATE2.
‎2006 Nov 16 8:15 AM
Salil,
subtract from-date from to-date which will give u always +ve value.
-Anu
‎2006 Nov 16 8:15 AM
data: l_diff type i.
l_diff = date1 - date2.
l_diff = abs( l_diff ).
if l_diff > 10.
**give error message.
endif.
Ramesh.
‎2006 Nov 16 8:33 AM
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
‎2006 Nov 16 8:41 AM
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.