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

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

问题描述

我们在 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.

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

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