mysql YYYY-MM-DDThh:mm:ss [英] mysql YYYY-MM-DDThh:mm:ss

查看:146
本文介绍了mysql YYYY-MM-DDThh:mm:ss的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mysql是否正确理解了dateTime类型的'YYYY-MM-DDThh:mm:ss'格式?
我有几个日期字段来自xml(类型为xsd:dateTime 'YYYY-MM-DDThh:mm:ss'格式)。然后我需要将这些字段保存到DB中(mysql dateTime格式为'YYYY-MM-DD hh:mm:ss')我应该将xml的日期格式转换为mysq日期格式 ?或者我可以将这些字段插入数据库而不转换?

Does mysql understand correctly 'YYYY-MM-DDThh:mm:ss' format for dateTime type? I have a few date fields which comes from xml (with type xsd:dateTime 'YYYY-MM-DDThh:mm:ss' format). Then I need to save these field into DB (mysql dateTime format is 'YYYY-MM-DD hh:mm:ss' ) Should I convert xml`s date format to mysq date format ? Or can I just insert these fields into the DB without converting?

推荐答案

是的,它是:


mysql> SELECT CAST('2010-12-30T01:02:03' AS datetime);
+-----------------------------------------+
| CAST('2010-12-30T01:02:03' AS datetime) |
+-----------------------------------------+
| 2010-12-30 01:02:03                     |
+-----------------------------------------+
1 row in set (0.08 sec)

mysql> SELECT CAST('2010-12-30 01:02:03' AS datetime);
+-----------------------------------------+
| CAST('2010-12-30 01:02:03' AS datetime) |
+-----------------------------------------+
| 2010-12-30 01:02:03                     |
+-----------------------------------------+
1 row in set (0.00 sec)

这篇关于mysql YYYY-MM-DDThh:mm:ss的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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