简体   繁体   English

DatetimePicker自动转换C#

[英]DatetimePicker automatic conversion C#

I am using C# and I am setting the value of the date time picker to my date from my database. 我正在使用C#,我正在从我的数据库中将日期时间选择器的值设置为我的日期。 But the format I have in database is different from the format of the Date Time Picker. 但我在数据库中的格式与日期时间选择器的格式不同。 Is there a way to automatically change the format of my database date to that of the date time picker. 有没有办法自动将我的数据库日期的格式更改为日期时间选择器的格式。 I have searched for it but I haven't found it. 我已经搜索过了,但我还没找到它。

I will appreciate your help. 我将感谢你的帮助。

But the format I have in database is different from the format of the Date Time Picke 但我在数据库中的格式与Date Time Picke的格式不同

You are making the mistake of thinking the database has any associated display format when storing a DATETIME - it doesn't - there is an internal representation. 在存储DATETIME时,您错误地认为数据库具有任何关联的显示格式 - 它没有 - 存在内部表示。 All you see is how the date is represented when you view it in some tool. 所有你看到的是当你在某个工具中查看它时如何表示日期。

If your database uses a DATETIME column, as it should, then there is not issue. 如果您的数据库使用DATETIME列,那么就没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM