You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Marco Gaido (JIRA)" <ji...@apache.org> on 2019/01/01 21:56:00 UTC

[jira] [Resolved] (SPARK-26515) SQL date_format function for 2018-12-30 returns 2019 date

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

Marco Gaido resolved SPARK-26515.
---------------------------------
    Resolution: Not A Bug

The problem is in your logic, namely in the format. You need {{yyyy}}, not {{YYYY}}. For further reference, please check https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html.

Please next time be careful about your code before opening ticket. Closing as not a bug. Thanks.

> SQL date_format function for 2018-12-30 returns 2019 date
> ---------------------------------------------------------
>
>                 Key: SPARK-26515
>                 URL: https://issues.apache.org/jira/browse/SPARK-26515
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.4.0
>         Environment: Ran in Zeppelin 0.8.0 with Spark 2.4.0
>            Reporter: David Thomasson
>            Priority: Major
>
> When running a query that formats the date '*2018*-12-30 03:16:04' to 'YYYY-MM-dd HH' the value returned is *2019*-12-30 03.
>  
> '*2018*-12-31 03:16:04' returns *2019*-12-31 03
> '*2018*-12-29 03:16:04' has no issues.
> '*2019*-12-29 03:16:04'  returns *2020*-12-29 03
> '*2017*-12-30 03:16:04' has no issues.
>  
> Example:
> sqlContext.sql("SELECT date_format('2018-12-30 03:16:04', 'YYYY-MM-dd HH') FROM example_df limit 1" ).show()
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org