datetime列的总计和小计

编程入门 行业动态 更新时间:2024-10-28 06:24:49
本文介绍了datetime列的总计和小计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我需要在gridview中找到datetime列的总数和小计。 iam使用gridview帮助程序( www.agrinei/gridviewhelper/gridviewhelper_en.htm [ ^ ]) 找到解决方案。它正在为整数值工作 为datetime列,它显示为字符串,例如。 08:30:0005:30:00,我需要结果 是

Hi guys, I need to find the total and subtotal of datetime column in gridview. iam using gridview helper( www.agrinei/gridviewhelper/gridviewhelper_en.htm[^] ) to find the solution.It is working for integer values for datetime column it is displaying as string eg. 08:30:0005:30:00,I need the result to be

1st row -> 08:30:00 2nd row -> 05:30:00 result -> 14:00:00

有人可以帮我找到解决方案。 提前致谢。

can anyone please help me to find the solution. Thanks in advance.

推荐答案

很明显,您获得了字符串连接,而不是数字计算。可能你只是在字符串上使用'+'运算符。 不,请看我对这个问题的评论。总结 System.DateTime 类型的对象根本就没有意义;它们代表时间轴上的点。 考虑使用 System.TimeSpan 。但在计算总和之前,您需要将字符串解析为此类型。请参阅名为 Parse , ParseExact , TryParse 的所有方法和 TryParseExact : msdn.microsoft/en-us/library/system.timespan_methods%28v=vs.110%29.aspx [ ^ ]。br />
-SA
It is apparent that you obtained string concatenation, and not numeric calculation. Probably you just used '+' operator on strings. No, please see my comment to the question. Summing up objects of the type System.DateTime makes no sense at all; they represents points on the time axis. Consider using System.TimeSpan instead. But before calculating the sum, you need to parse the string to this type. Please see all the methods named Parse, ParseExact, TryParse and TryParseExact: msdn.microsoft/en-us/library/system.timespan_methods%28v=vs.110%29.aspx[^].
—SA

更多推荐

datetime列的总计和小计

本文发布于:2023-07-08 19:48:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1079987.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:小计   datetime

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!