本文介绍了我在MySql中存储和检索正确的日期/时间时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI
我已经在Mysql中创建了一个数据库,并且在其中一个表中有一个datetime字段.在我的C Sharp代码中,我创建一个DateTime对象,然后尝试保存在数据库字段中.日期和时间保存在数据库中,但是不正确.我有一个问题,当我将DateTime.Now.ToString()保存到我的数据库时出现错误,它说日期/时间格式不正确. Mysql中的日期分隔符是-",C#使用"/",因此我操纵了字符串,并用-"替换了"/",它似乎起作用了. 有人知道如何解决吗? :confused:

在此先感谢您的帮助!

HI
I have created a database in Mysql and i have a datetime field in one of my tables. In my C Sharp code i create a DateTime object and i try to save in my database field. The date and time saves in the database but it is incorrect. I had the problem where i was getting an error when i saved DateTime.Now.ToString() to my database, it said incorrect date/time format. The date seperator in Mysql was a "-" and C# used a "/", so i manipulated the string and replaced "/" with "-" and it seemed to worked. Does anyone know how to solve this? :confused:

Thanks in advance for you help!

推荐答案



这篇关于我在MySql中存储和检索正确的日期/时间时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 04:22