2006 Mar 20 5:04 AM
hi ..
i want to know diff between two dates . please help me in this regard...
thanks in advance..
hi ..
i want to know diff between two dates . please help me in this regard...
thanks in advance..
2006 Mar 20 5:08 AM
2006 Mar 20 5:10 AM
Hai sharadha,
I've just tried in my system, its working
REPORT YRT_TEST1.
parameters : date1 like sy-datum,
date2 like sy-datum.
data: days(3) type n.
data: years(10) type p decimals 3.
start-of-selection.
days = date2 - date1.
years = days / 365.
write: / days,
years.
Regards,
Srikanth.
Reward points if helpful.
2006 Mar 20 5:12 AM
Hi,
If you want to use a Function Module..
Here is the Sample code....
REPORT ZDATEDIFF.
DATA: EDAYS LIKE VTBBEWE-ATAGE,
EMONTHS LIKE VTBBEWE-ATAGE,
EYEARS LIKE VTBBEWE-ATAGE.
PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
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.
WRITE:/ 'Difference in Days ', EDAYS.
WRITE:/ 'Difference in Months ', EMONTHS.
WRITE:/ 'Difference in Years ', EYEARS.
INITIALIZATION.
FROMDATE = SY-DATUM - 60.
Regards,
Srikanth.
reward points if helpful.
2006 Mar 20 5:48 AM
Hi,
try it this way too:
data: d1 like sy-datum,
d2 like sy-datum.
data: diff type i.
d1 = '20060331'.
d2 = '20060220'.
diff = d1 - d2.
write : / diff .
Also chek these FMs:
'CSCP_PARA1_GET_PERIODS'
HR_99S_INTERVAL_BETWEEN_DATES(Months, Years and days)
COMPUTE_YEARS_BETWEEN_DATES
EHS_CALC_YEARS_BETWEEN_DATES
DAYS_BETWEEN_TWO_DATES
MONTHS_BETWEEN_TWO_DATES
And for no of week days between two dates
Hope that helps you.
Regards,
Anjali
2006 Mar 20 5:54 AM
Hi Sharadha,
Are you looking for the days between two dates as the difference or just the difference between two dates in the date format only.
For <b>First</b> option:
Try this
DATA V_DIFF TYPE I.
PARAMETERS P_BIRTHD LIKE SY-DATUM.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = SY-DATUM
I_DATUM_VON = P_BIRTHD
IMPORTING
E_TAGE = V_DIFF
EXCEPTIONS
DAYS_METHOD_NOT_DEFINED = 1
OTHERS = 2.
IF SY-SUBRC EQ 0.
WRITE:/ V_DIFF, 'DAYS HAVE PASSED SINCE', P_BIRTHD.
ELSE.
WRITE:/ 'ERROR IN CALCULATION'.
ENDIF.
This will give the difference between two dates:
*<b>Second</b>
You can simply subtract both the dates as suggested above inorder to have the date difference in the date format.
Hope this will help you.
If ur satisfied then please close this thread by rewarding appropraite points to the helpful answers.
Cheers
Sunny
2006 Mar 20 6:43 AM
Hai Sharadha,
Please reward points and close the thread if at all your doubt is cleared.
Regards,
Srikanth.
2006 Mar 20 8:13 AM
Hi Sharadha ,
you can use this function module
in this field "i_time_uom " give the unit of measure
H -hours
d- days
s - seconds.
so the resultant can be calculated in any of the above mentioned units.
Do reward points if useful and close the thread if the doubt is cleared.
Regards,
Kishore Kumar Yerra.
call function 'L_TO_TIME_DIFF'
exporting
i_start_date = i_qmel-strmn
i_start_time = i_qmel-strur
i_end_date = i_final-budat2
i_end_time = i_final-erzet2
i_time_uom = 'H'
importing
e_time_diff = ydatdiff
* EXCEPTIONS
* INPUT_DATA_EMPTY = 1
* OTHERS = 2
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
2006 Mar 20 8:23 AM
Hi sharadha,
use this function module .
HR_SGPBS_YRS_MTHS_DAYS.
just pass the Two Dates u want to know the difference and it will give the diff in years , months and days .
i hope u r looking for diff between two dates .
substracting the dates directly may give u correct answers in a particular year but this does not always reveal exact solutions.
regards,
Vikky.
regards,
Vikky.
2006 Mar 20 9:34 AM
Hi sharadha,
In ABAP 'd' is the Date Type.
For Eg.
data old type d.Here old is of type date.
In orfer to find difference between the dates just use the '-'(minu) operator.
For Eg.
data old type d. "In format yyyymmdd.
data new type d. "y - year, m - month & d - day
data diff type i."No. of days
OLD = '20060101'. "Date of 8 charecter
NEW = '20060102'. "Should be assigned in format yyyymmdd.
if(old > new).
diff = old - new.
else.
diff = new - old.
endif.Hope it helps.
Regards,
Maheswaran.B
Message was edited by: Maheswaran B
Message was edited by: Maheswaran B
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |