1 of 1 people found this helpful
When comparing numeric values such as:
Month_Length and ((Int(Number_of_Days / 30.4375) ) ) < "1"
Don't enclose the numbers in quotes.
A simpler way to get the number of days in a month:
Day ( Date ( Month ( YourDateFieldHere ) + 1 ; 0 ; Year ( YourDateFieldHere ) ) )
You can use any date that falls in the month for which you need the number of days.
Don't forget there was a 2-29-2016 this year. Your result is correct. If you change your Decommission Date to 12-6-2016 your time elapsed will be 1 day. FileMaker's Date and Timestamp fields account Leap Years.
Allen you are totally correct.
What a great brain fart on my end.
Thank you Phil for your suggestion. I have removed the quotes on the numbers.
Thank you all.
Actually, I think your calc is not correct after all. Try this one (unstored):
Let ( [
C = Get ( CurrentDate ) ;
yC = Year ( C ) ;
mC = Month ( C ) ;
dC = Day ( C ) ;
doyC = DayOfYear ( C ) ;
B = Commission ;
yB = Year ( B ) ;
mB = Month ( B ) ;
dB = Day ( B ) ;
doyB = DayOfYear ( Date( mB ; dB ; yC ) ) ;
num_years = ( yC - yB - ( doyC < doyB ) ) ;
num_months = Mod ( mC - mB - (dC < dB ) ; 12 ) ;
num_days = C - Date ( mC - ( dC < dB ) ; dB ; yC ) ] ;
num_years & " Years, " & num_months & " Months, " & num_days & " Days")
If Commission Date is 12-6-2015, using the above, you should get 1 year, 0 months, 1 day.
Right. But 2016 is a leap year, adding an extra day.
Therefore, having that calculation equal 1 year, 0 months, 2 days will be correct.
The time elapsed in days between 12-6-2015 and 12-7-2016 is 367 (12-6-2014 to 12-7-2015 is 366). But 12-7-2016 is 1 year, 0 months, and 1 day removed from 12-6-2015.