title: Date and Interval Addition in SparkSQL
body: <p>I am trying to execute a simple SQL query on some dataframe in spark-shell the query adds interval of 1 week to some date as follows:</p>
  
  <p>The original query:</p>
  
  <pre><code>scala&gt; spark.sql("select Cast(table1.date2 as Date) + interval 1 week from table1").show()
  </code></pre>
  
  <p>Now when I did some tests:</p>
  
  <pre><code>scala&gt; spark.sql("select Cast('1999-09-19' as Date) + interval 1 week from table1").show()
  </code></pre>
  
  <p>I got the results correctly</p>
  
  <pre><code>+----------------------------------------------------------------------------+
  |CAST(CAST(CAST(1999-09-19 AS DATE) AS TIMESTAMP) + interval 1 weeks AS DATE)|
  +----------------------------------------------------------------------------+
  |                                                                  1999-09-26|
  +----------------------------------------------------------------------------+
  </code></pre>
  
  <p>(Just adding 7 days to 19 = 26)</p>
  
  <p>But when I just changed the year to 1997 instead of 1999 the results changed!</p>
  
  <pre><code>scala&gt; spark.sql("select Cast('1997-09-19' as Date) + interval 1 week from table1").show()
  
  +----------------------------------------------------------------------------+
  |CAST(CAST(CAST(1997-09-19 AS DATE) AS TIMESTAMP) + interval 1 weeks AS DATE)|
  +----------------------------------------------------------------------------+
  |                                                                  1997-09-25|
  +----------------------------------------------------------------------------+
  </code></pre>
  
  <p>Why the reuslts changed? Shouldn't it be 26 not 25?</p>
  
  <p><strong>So, is this a bug in sparkSQL related to some kind of itermediate calculations loss or I am missing something?</strong></p>