Managed Hosting



Flex Date Utils
Project Home Blog Forums Known Issues External Project Link Contact Project

Flex Date Utils Issue: dateDiff wrong calculations

Name: dateDiff wrong calculations
ID: 6
Project: Flex Date Utils
Type: Bug
Area: Code
Severity: High
Status: Open
Related URL:
Creator: Roberto Lo Giacco
Created: 02/22/11 3:35 PM
Updated: 06/14/11 9:08 AM
Description: DateUtils.dateDiff("month", "19 feb 2012", "21 feb 2009") returns a wrong value of 1 and DateUtils.dateDiff("month", "22 feb 2009", "21 feb 2011") returns a wrong value of 11.

I've tried different combinations and it seems the bug happens quite often.
History: Created by rlogiacco (Roberto Lo Giacco) : 02/22/11 3:35 PM

Comment by brianbishop (Brian Bishop) : 06/14/11 6:51 AM
Having similar type problems:

start="2011-06-13 00:00:00.000 -0500"
end="2013-06-12 23:59:59.000 -0500"

DateUtils.dateDiff( DateUtils.MONTH, start, end);

Returns 12 instead of 24.

Comment by Lampei (Gareth Arch) : 06/14/11 7:26 AM
I'm backed up a bit with work lately, and probably won't be able to get to this for a few weeks, but if either of you guys want to tinker with the code, it's up on the google code base (link in the project). If you can narrow it down (and even throw in the fix), I'll update the code.

Comment by brianbishop (Brian Bishop) : 06/14/11 9:08 AM


I have narrowed down my problem to setting the endDate to 23:59:59, and in the dateDiff() function it checks:

endDate.dateUTC < startDate.dateUTC

Because I am using a US timezone for testing, the endDates dateUTC = 14, whereas the endDates date = 13. The startDate's dateUTC and date are both 14.

Should it just be using endDate.date and startDate.date? Basically returns 0 instead of 12 months, or 12 instead of 24 months.

Brian Bishop

To add a comment to this bug, please login using the link above.