[ 
https://issues.apache.org/jira/browse/HIVE-1253?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bryan Talbot updated HIVE-1253:
-------------------------------

    Affects Version/s:     (was: 0.5.0)
                       0.6.0
         Release Note: Fix off-by-one issue with date_sub and date_add when 
date ranges include a daylight savings time change.
               Status: Patch Available  (was: Open)

date_sub and date_add used both a Calendar and a SimpleDateFormat object; 
however, the UTC timezone was only set for the Calendar object.  This causes 
the computation to sometimes be incorrect when the date ranges cross daylight 
savings time changes.

The patch removes specifying the UTC timezone for the Calendar object so that 
both Calendar and the SimpleDateFormat will use the default timezone.  This 
should allow the date math to be consistent with other potential date math 
functions as long as they all use the default timezone.

If the user wishes to use a specific timezone that is not the system default, 
it can be set using the normal java ways (e.g. setting user.timezone, etc.).


> date_sub() function returns wrong date because of daylight saving time 
> difference
> ---------------------------------------------------------------------------------
>
>                 Key: HIVE-1253
>                 URL: https://issues.apache.org/jira/browse/HIVE-1253
>             Project: Hadoop Hive
>          Issue Type: Bug
>          Components: Query Processor
>    Affects Versions: 0.6.0
>            Reporter: mingran wang
>
> date_sub('2010-03-15', 7) returns '2010-03-07'. This is because we have time 
> shifts on 2010-03-14 for daylight saving time.
> Looking at ql/src/java/org/apache/hadoop/hive/ql/udf/UDFDateSub.java, it is 
> getting a calendar instance in UTC time zone.
> def calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
> And use calendar.add() to substract 7 days, then conver the time to 
> 'yyyy-MM-dd' format.
> If it simply uses default timezone, the problem is solved: "def calendar = 
> Calendar.getInstance());"
> When people use date_sub('2010-03-15', 7), I think they mean substract 7 
> days, instead of substracting 7*24 hours. So it should be an easy fix. The 
> same changes should go to date_add and date_diff

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to