# Calculating Elapsed Time Between two dates

Discussion created by JulioSandoval on Dec 7, 2016
Latest reply on Dec 7, 2016 by alquimby

Hello All,

So I don't know if anyone else has had this issue before. But I like how the FM KB had this calculation as an example. But here is what I have:

I have it set to use CurrentDate IF DecomissionDate is empty.

Number_Of_Days Script:

If (

IsEmpty ( DecomissionDate ) ;

Get(CurrentDate)  ; DecomissionDate

)

- CommissionedDate

Month_Length:

Case(

Month(CommissionedDate) = "1"; "31" ;

Month(CommissionedDate) = "2" ; "28" ;

Month(CommissionedDate) = "3" ; "31" ;

Month(CommissionedDate) = "4" ; "30" ;

Month(CommissionedDate) = "5" ; "31" ;

Month(CommissionedDate) = "6" ; "30" ;

Month(CommissionedDate) = "7" ; "31" ;

Month(CommissionedDate) = "8" ; "31" ;

Month(CommissionedDate) = "9" ; "30" ;

Month(CommissionedDate) = "10" ; "31" ;

Month(CommissionedDate) = "11" ; "30" ;

Month(CommissionedDate) = "12" ; "31"

)

Final Script:

Time_Lapsed:

(Int(

Number_of_Days / 365.25 )) &

" Years " & If(

(Round( Mod( Number_of_Days ; 30.4375 ) ; 0 )) <=

Month_Length and ((Int(Number_of_Days / 30.4375) ) ) < "1" ; "0" ;

((Int(Number_of_Days / 30.4375) - (12 * (Int( Number_of_Days / 365.25 )))))

)

& " Months " & (Round( Mod( Number_of_Days ; 30.4375 ) ; 0 )) & " Days"

Script Reference:

Issue:

If I have a date of 12/06/2015 , the Lapsed time shows 1 years, 0 Months, 2 Days.

It is currently 12/07/2016 which should make it 1 Day not 2...

Any thoughts would help greatly.

Thank you all.