如何更改数据库的 MySQL 日期格式?

2022-01-12 00:00:00 date formatting mysql filemaker

我们在 FileMaker 中使用 MySQL 数据库.看来 FileMaker 在读取 MySQL 表时,只会接受 m/d/y 格式的日期.

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.

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

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?

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

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.

推荐答案

多读一点发现可以更改特定字段的格式 但不建议这样做.

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

您无法更改存储格式

你可以设置 ALLOW_INVALID_DATES 并以您希望的格式保存日期,但我真的不建议这样做.

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

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

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.

相关文章