日期时间在导出为CSV时被截断 [英] Datetime truncated on exporting to CSV

查看:355
本文介绍了日期时间在导出为CSV时被截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况1:
我在UI屏幕上有这样的内容
  2015/5/30 10:09:48 ....这已转换为 5/30/2015 10:09
我在获取中使用DateTime类型,设置并在导出时将其转换为字符串

case 1:
I have something like this on the UI screen
 5/30/2015 10:09:48 AM .... This is getting converted to 5/30/2015 10:09
I am using DateTime type in the get, set and converting it to string while exporting

情况2:
00:00:40.020(hh:mm:ss:milliseconds)正在转换为 00:40.0
使用TimeSpan类型进行获取,设置

case 2:
00:00:40.020 (hh:mm:ss:milliseconds)  is getting converted to 00:40.0
Using a TimeSpan type for get, set

(导出到pdf没问题)
如何阻止CSV导出.我需要导出的总日期时间.请帮忙!

(There is no problem exporting to pdf)
How can I prevent this for CSV export. I need the total datetime on exporting. Please help!!

推荐答案

您没有共享要检查的转换代码,请检查以下格式并尝试第一个情况下,这会将日期转换为特定格式的字符串:

You didn't share the conversion code to check, check the below format and give a try for the first case, this will will convert date to string in a specific format:

var date11 = string.Format("{0:MM/dd/yyyy HH:mm:ss tt}", DateTime.Parse(yourdatevaluehere));

还有一次:

var date11 = string.Format("{0:HH:mm:ss fff}", DateTime.Parse(yourdatevaluehere));


这篇关于日期时间在导出为CSV时被截断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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