如何更改数据库的MySQL日期格式? [英] How to change MySQL date format for database?

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

问题描述

我们正在使用带有FileMaker的MySQL数据库。看来,当FileMaker读取MySQL表时,它只会接受m / d / y格式的日期。



有什么办法可以让我们的MySQL数据库将其默认格式更改为m / d / y而不是YYYY-MM-DD?



我知道我可以在单个SELECT查询中使用DATE_FORMAT()函数但是我想看看是否可以更改默认格式。

解决方案

编辑1



阅读更多我发现您可以更改特定的格式字段,但不推荐。



您无法更改存储空间格式



您可以设置 ALLOW_INVALID_DATES ,并以您希望的格式保存日期,但我不建议。



如果您的字段未被编入索引,则在执行选择时没有问题调用 DATE_FORMAT() ,唯一的问题是如果您需要为该字段进行选择,在这种情况下,由于您正在调用该函数,索引将不被使用。


We are using a MySQL database with FileMaker. It appears that when FileMaker is reading the MySQL tables, it will only accept dates in the format of m/d/y.

Is there any way I can get our MySQL database to change its default format to be m/d/y instead of YYYY-MM-DD?

I know I can use the DATE_FORMAT() function on individual SELECT queries but I want to see if I can just change the default formatting.

解决方案

Edit 1

Reading a little more I found you can change the format for an specific field but there is not recommended.

you cannot change the storage format

you could set ALLOW_INVALID_DATES and save the dates with the format you wish but I really don't recommend that.

if your field isn't indexed there is not issue on call DATE_FORMAT() when you are doing the select, the only issue is if you need to make a select for that field in which case the index wont be used because you are calling the function.

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

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