title: How to calculate difference between date column and current date?
body: <p>I am trying to calculate the Date Diff between a column field and current date of the system. </p>
  
  <p>Here is my sample code where I have hard coded the my column field with  20170126.</p>
  
  <pre><code>val currentDate = java.time.LocalDate.now
  var datediff = spark.sqlContext.sql("""Select  datediff(to_date('$currentDate'),to_date(DATE_FORMAT(CAST(unix_timestamp( cast('20170126' as String), 'yyyyMMdd') AS TIMESTAMP), 'yyyy-MM-dd'))) AS  GAP
          """)
  datediff.show()
  
  Output is like:
  +----+
  | GAP|
  +----+
  |null|
  +----+ 
  </code></pre>
  
  <p>I need to calculate actual Gap Between the two dates but getting <code>NULL</code>.</p>