Date_format转换为边界日期增加了1年 [英] Date_format conversion is adding 1 year to the border dates

查看:153
本文介绍了Date_format转换为边界日期增加了1年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在12月31日使用DATE_FORMAT时 2018年将更改为2019年.有人可以帮忙说一下这是一个错误还是我丢失了某些东西.

When I use DATE_FORMAT for Dec 31st date 2018 year is getting changed to 2019. Can someone help say if this is a bug or I am missing something.

import org.apache.spark.sql.functions._

spark.sql("select CAST(1546268400 AS TIMESTAMP)").show(false)

输出:2018-12-31 15:00:00.0

Output: 2018-12-31 15:00:00.0

spark.sql("select DATE_FORMAT(CAST(1546268400 AS TIMESTAMP), 'MM/dd/YYYY HH:mm')").show(false)

输出:12/31/ 2019 15:00

Output: 12/31/2019 15:00

推荐答案

因此,这不能完全准确地回答您的问题,但是在这里使用YYYY vs yyyy似乎至关重要.仍在实际调查中,但这也可以帮助您找出答案.

So this doesn't exactly answer your question but the use of YYYY vs yyyy seems crucial here. Still investigating actually, but this might help you to figure it out as well.

更新: https://github.com/davedelong/calendar_fallacies/issues/26

YYYYyyyy之间的区别是ISO_Week Year与日历年.

The distinction between YYYY and yyyy is ISO_Week Year vs calendar year.

这篇关于Date_format转换为边界日期增加了1年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆