将德国日期转换为DateTime格式时出现问题 [英] Problem in converting German dates to DateTime format

查看:166
本文介绍了将德国日期转换为DateTime格式时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的应用程序出现问题.
我正在将数据从文本文件导入数据库表.
我的字段之一是DateTime数据类型.
现在,问题在于日期在该文本文件中以德语编写,例如:10年3月31日写为31-Mrz-10,而10年5月1日写为1-Mai-10.
导入时,它给我错误,因为字符串不是有效的DateTime格式".

谁能告诉我如何将这些德国数据时间字符串转换为DateTime格式.

谢谢,
Nagendra.

解决方案

您可以使用转换 [ ^ ]来更改数据类型.查看文档中的日期和时间样式".

另一种选择是使用C#进行重新格式化和转换,并使用 DateTime.Parse [ ^ ]


Hello all,

I am getting a problem in my application.
I am importing data from a text file into a database table.
One of my field is of DateTime datatype.
Now, problem is dates are written in German language in that text file, for e.g.: 31-Mar-10 is written as 31-Mrz-10 and 1-May-10 is written as 1-Mai-10.
While importing, it is giving me error as "String is not a valid DateTime format".

Can anyone tell me how can i convert these german datatime strings to DateTime format.

Thanks,
Nagendra.

解决方案

You can use Convert[^] to change the datatype. Have a look at the "Date and time styles" in the documentation.

Another option is to make the reformat and conversion in C# and use DateTime.Parse[^]


这篇关于将德国日期转换为DateTime格式时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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