10-16-2007 6:24 AM
Hi,
I am working on function module. my requirement is if i will give from date and to date out put will be in no of days.
Regards
Srinu
10-16-2007 6:27 AM
Hi Sreenivas,
Just calculate the difference between two dates using arithmetic subtract operator.
DATA V_DAYS TYPE I.
V_DAYS = TO_DATE - FROM_DATE.
Give the TO_DATE and FROM_DATE to the function module as IMPORT parameters and calculate the difference in the source code and display the difference using WRITE statement.
Thanks,
Vinay
10-16-2007 6:30 AM
hi
DATA: To_date type sy-datum,
From_date type sy-datum,
days type i.
days = To_date - From_date + 1.
Write:/ 'The no of days :', days.
10-16-2007 6:31 AM
hi
U can use DAYS_BETWEEN_TWO_DATES.
Sample :
REPORT ZEXAMPLE.
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.
<b>
reward points for useful ans</b>
regards
Aarti
10-16-2007 7:11 AM
Hi arthi,
i created function module in the se37. i given import parameters date1 and date.Export parameter no_days.In the source code tab i writen foloing code.
IF DATE1 < DATE2.
RAISE V_EXC.
NO_DAYS = DATE1 - DATE2.
ENDIF.
ENDFUNCTION.
Regards
Srinu
10-16-2007 6:44 AM
hi! sreenivaslu
can do by getting
1. FROM_DATE and TO_DATE in Import parameters.
2. subtract using Arithmetic Operator
date1 = to_date - from_date.
this will give you the difference of dates which you want
3. can display this value in EXPORT Parameter.
(OR)
Using the Function Module DAYS_BETWEEN_TWO_DATES
1. Pass the From and To dates as Input
2. Get the day to a variable
3. Pass this variable as the EXPORT Parameters variable.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = TO_DATE
I_DATUM_VON = FROM_DATE
IMPORTING
E_TAGE = DATE
Reagrds,
Nagulan
Reward me if its Useful.
10-16-2007 6:49 AM
hi,
try using :
FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.
or
HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months
might be useful..
regrads,
ritika malhotra
Message was edited by:
ritika malhotra
10-16-2007 6:54 AM
Use the standard function module as suggested by others. If your problem is solved, please close this thread.