MySQL日期格式更改 [英] MySQL date format change

查看:81
本文介绍了MySQL日期格式更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有数据加载到格式为8/21/2013的varchar字段中,我需要将其字符串化为日期并将其以正确的格式放入2013-08-21.香港专业教育学院尝试字符串日期和日期格式,但必须有一种方法来指定它在%m/%d/%y中,并需要它%y-%m-%d.现在我收到此错误[Err] 1292-错误的日期时间值:"08-21-2013"(如果未识别出上个月,我将其设为0)

Hi I have data I load to a varchar field in format 8/21/2013, I need it to string to date and put it in the correct format 2013-08-21. Ive tried string to date and date format but there must be a way to specify that it is in %m/%d/%y and in need it %y-%m-%d. right now I get this error [Err] 1292 - Incorrect datetime value: '08-21-2013' (I concated a 0 incase it didnt recognize the above month)

推荐答案

您切换了日期和月份.没有月份号21,这就是为什么您会收到此错误.试试

You switched days and month. There's no month number 21, that's why you get this error. Try

SELECT STR_TO_DATE('8/21/2013', '%m/%d/%Y');

这篇关于MySQL日期格式更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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