在MYSQL中创建表时如何更改默认日期格式 [英] how to change default date format when creating table in MYSQL

查看:676
本文介绍了在MYSQL中创建表时如何更改默认日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MySQL中创建表格时如何更改默认日期格式

how to change default date format when creating table in MYSQL

推荐答案

在表定义阶段,不能更改日期的默认格式. (它必须始终遵循DATETIME,DATE或TIMESTAMP格式.)如手册所述:

You can't change the default format for a date during the table definition stage. (It must always obey the DATETIME, DATE or TIMESTAMP formats.) As the manual puts it:

尽管MySQL试图解释 多种格式的值,日期 始终必须在年-月-日中给出 订单(例如,"98-09-04"), 而不是月-日-年或 常用的日-月-年订单 其他地方(例如,"09-04-98", '04 -09-98').

Although MySQL tries to interpret values in several formats, dates always must be given in year-month-day order (for example, '98-09-04'), rather than in the month-day-year or day-month-year orders commonly used elsewhere (for example, '09-04-98', '04-09-98').

请参见日期和时间参考文档了解更多信息.

因此,您必须使用

As such, you'll have to use the DATE_FORMAT() function at the point of output to achieve this goal.

这篇关于在MYSQL中创建表时如何更改默认日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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