C#data tow中日期时间格式的问题 [英] problem with datetime format in C# data tow
本文介绍了C#data tow中日期时间格式的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的数据表数据行包含日期格式为
my data row for data table contain date in a format
dd-MM-yyyy hh:mm::ss:AM
check two''::分钟后的符号。我无法转换/读取此值作为datetime是否有任何解决方案,它总是抛出无效的日期格式PLZ帮助
check Two ''::'' symbol after minutes. I can''t convert /read this value as datetime is there any solution for this it always throw invalid date formatt PLz help
推荐答案
将我的代码更正为您的格式。经过测试和工作:
Corrected my code to your format . Tested it and working:
DateTime date;
if (DateTime.TryParseExact("21-01-2009 14:59::59:PM", "dd-MM-yyyy HH:mm::ss:tt", CultureInfo.GetCultureInfo("en-GB"), DateTimeStyles.None, out date))
{
MessageBox.Show("Success");
}
if (DateTime.TryParse(dr["PatientCreationDate"].ToString().Replace("::",":"), out TempDate))
{
CreationDate = TempDate;
}
快乐编码!
:)
Happy Coding!
:)
这篇关于C#data tow中日期时间格式的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文