如何更改数据库的MySQL日期格式? [英] How to change MySQL date format for database?
问题描述
有什么办法可以让我们的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屋!