如何计算VB.NET中的时差 [英] How to calculate time difference in VB.NET
本文介绍了如何计算VB.NET中的时差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Starttime = 10:25:06 AM
EndTime = 1:25:06 PM
result = Starttime.substract(EndTime)
结果= 8:00:00
结果错了
请帮帮我
我尝试过:
Starttime=10:25:06 AM
EndTime=1:25:06 PM
result=Starttime.substract(EndTime)
Result=8:00:00
Result is wrong
please help me
What I have tried:
Starttime=10:25:06 AM
EndTime=1:25:06 PM
result=Starttime.substract(EndTime)
Result=8:00:00
Result is wrong
please help me
推荐答案
实现这一目标的方法很少:
#1
DateDiff函数(Visual Basic) [ ^ ]
#2
在vb.net中获取两个时间跨度之间的时差 - Stack Overflow [ ^ ]
有关详细信息,我建议阅读MSDN文档:使用日期和时间执行算术运算 [ ^ ]
There's few ways to achieve that:
#1
DateDiff Function (Visual Basic)[^]
#2
Get time difference between two timespan in vb.net - Stack Overflow[^]
For further details, i'd suggest to read MSDN documentation: Performing Arithmetic Operations with Dates and Times[^]
您可以尝试以下内容 -
You can try something like following-
Dim Starttime As New DateTime(2017, 1, 1, 10, 25, 6) ' 10:25:06 AM
Dim EndTime As New DateTime(2017, 1, 1, 13, 25, 6) ' 1:25:06 PM
Dim Result As TimeSpan = EndTime - Starttime
希望,它帮助:)
Hope, it helps :)
这篇关于如何计算VB.NET中的时差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文