alagar
alagar

Reputation: 134

mysql YYYY-MM-DDThh:mm:ss

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?

Upvotes: 1

Views: 5644

Answers (1)

GreyCat
GreyCat

Reputation: 17104

Yes, it does:

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)

Upvotes: 5

Related Questions