Date Calculation incorrect for date ranges that span the month of November

Issue #38 resolved
Former user created an issue

We are using the Mathematical or date-time expression calculator post function to add days (specified in a custom number field) to a custom date field. The function works as expected, except when the date period includes November, in which case the end date is one day less than expected.

I have attached an image of the results.

The dates we tested were ok, except for:

Nov. 1, 2014 + 32 days = Dec. 2, 2014 (should be Dec. 3, 2014) Oct 1, 2014 + 60 days = Nov. 29, 2014 (should be Nov. 30, 2014) Nov. 1, 2014 + 60 days = Dec. 30, 2014 (should be Dec. 31, 2014)

Also tried in different years with same result

Comments (6)

  1. Fidel Castro Armario repo owner

    Hi,

    I haven't been able to reproduce your problem. I have implemented the three examples you describe and I'm getting the expected results.

    I have used a Date Time Picker custom field called Date Time 1 (field code {10004}) with the following configurations of post-function Mathematical or date-time expression calculator:

    Captura de pantalla 2014-04-16 a la(s) 11.21.30.png

    and

    Captura de pantalla 2014-04-16 a la(s) 11.20.56.png

    I'm using JIRA Workflow Toolbox 2.1.15 installed on JIRA 6.2.3. The timezones of my user and the server are the same: (GMT+01:00) Madrid.

    I need some information to reproduce your problem: Which timezone is configured in your server and in the user you are using for doing these tests? Which version of JIRA are you using?

    A screenshot of the formula you are using in post-function Mathematical or date-time expression calculator might be helpful.

  2. Brad Jesty

    The formula is (I am having trouble attaching a screen shot):

    {10451} + {11446} * {DAY}

    The first field is the date and second field is a number containing the number of days to add to the date. I have updated the plugin to version 2.1.15 and am still seeing the same results.

    We are using JIRA version 6.1.3 and JAVA version 1.7.0_21.

    The timezone is America/Montreal (Eastern, GMT-05:00)

  3. Fidel Castro Armario repo owner

    Can you please try the same test but setting the hour part of the field {10451} to 2:00 AM?

    I mean, in your first example, initialize field to Nov. 1, 2014 2:00 AM.

    If field {10451} doesn't allow to set hour, please, do the test with the following formula:

    {10451} + {11446} * {DAY} + 2 * {HOUR}

  4. Brad Jesty

    This seems to work for both the dates that were causing problems and for some other dates that weren't a problem as well. Is it a reliable work around for all dates?

  5. Fidel Castro Armario repo owner

    The cause of your problem is that on 2th November it is scheduled the next DST transition in your timezone. So, on that date 1 hour is subtracted from current time, and if you are doing calculations with a field set at 00:00 time, it will be set to day before than expected at 23:00.

    To avoid this inconvenience you can add 1 hour. This solution isn't a problem when you are working with custom fields of type Date Picker, since these kind of fields remove the time part, but in case you are using fields of type Date Time Picker you can use the following formula:

    {10451} + {11446} * {DAY} + 2 * {HOUR} - timePart({10451} + {11446} * {DAY} + 2 * {HOUR}, LOCAL)

    This formula has an additional terminus for subtracting the time part. Of course, you can also use this formula with custom fields of type Date Picker.

  6. Log in to comment