I am working on a function to report the total Years, Months, Days, Hours, Minutes, Seconds between two date stamps.
I have most of it working but in my testing realized something. The following gives incorrect output:
Despite only being a day and a half different, DateDiff reports there is a whole month between the dates. I am assuming that DateDiff is rounding up from a decimal. Anyone know how I can get anything less than a full month to report as zero months?
I considered using the number of days total between them, but converting days to months & days using MOD is not accurate either since the number of days in a month varies.
Any help appreciated.
I have most of it working but in my testing realized something. The following gives incorrect output:
Code:
sTime = "7/29/2007 4:15:00 AM"
eTime = "8/1/2007 6:29:50 PM"
WScript.Echo datediffToWords(sTime, eTime)
Function datediffToWords(d1, d2)
months = Int(DateDiff("m",d1,d2))
WScript.Echo months & " months"
End Function
Despite only being a day and a half different, DateDiff reports there is a whole month between the dates. I am assuming that DateDiff is rounding up from a decimal. Anyone know how I can get anything less than a full month to report as zero months?
I considered using the number of days total between them, but converting days to months & days using MOD is not accurate either since the number of days in a month varies.
Any help appreciated.