从c#中读取数据时的日期问题 [英] Date issue while reading data from excel in c#

查看:63
本文介绍了从c#中读取数据时的日期问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Excel读取数据



在某些文件中返回日期值错误



例如。 returnig 30-10-2014 12:00 PM 30-10-02014 12:00 PM

while Reading Data from Excel

in some file it returning Date values wrong

for eg. returnig 30-10-2014 12:00 PM as 30-10-02014 12:00 PM

推荐答案

首先查看数据源:最可能的原因是用户在输入日期时出现手指故障。

这看起来像基于字符串的日期表示,而不是基于日期的项目。所以阅读它们,然后循环查看是否有任何一个失败的TryParseExact(dd-MM-yyyy hh:mm tt,......如果有,那就是问题。
Start by looking at the data source: the most likely reason is "finger trouble" from the user when he input the date.
That looks like a string based date representation, rather than a date based item. So read them, then loop through and see if any of them fail a TryParseExact("dd-MM-yyyy hh:mm tt", ... If they do, that's the problem.


这篇关于从c#中读取数据时的日期问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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