masters in my application i have to compare 2 dates in 2 variable
var1 var2 i have to check whether var1 is greater then var2 or not how to do it please tell me
Moderator message: very basic, please search for information before posting.
Message was edited by: Thomas Zloch
Request clarification before answering.
Use FM HR_HK_DIFF_BT_2_DATES to get difference between two dates .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can simply use the relational operators > or < on your dates if they are in the internal date format (YYYYMMDD).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi ravi
you can compare dates by simply using the keyword GT .
Ex:
If d1 gt d2 .
write d1.
else .
write d2.
endif.
regards
vaibhav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can simply do it as follow:
if date1 gt date2.
write:'date1 is greater then date2 '.
else.
write:'date2 is greater then date1 '.
endif.
Your code is not working because:
l_diff must be of type sy-datum ,Since date1 and date2 are of type sy-datum,else proper conversion will not haapen.In your code i_diff is of type 'i'.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ravi kumar,
First declare two variable with data type D,
Then you can easily compare these variable with arithmetic operators.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please check the below link which will give function modules available for calculating date related operations.
http://scn.sap.com/thread/3283689
hope this helps
Hi,
You can compare like
if var1 < var2
----Do Some thing-----
endif.
Hope this will help.
Regards,
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can compare dates using simple mathematical operators.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
May be the dates are in different format than the MMDDYYYY format. so you can either mask them to this format or use the following module ...
call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from = FROMDATE
i_date_to = TODATE
* I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = EDAYS
E_MONTHS = EMONTHS.
* E_YEARS = EYEARS.
| User | Count |
|---|---|
| 14 | |
| 12 | |
| 7 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.