总和分钟与2次 [英] sum minute with 2 time

查看:119
本文介绍了总和分钟与2次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何用不同日期的2次总和分钟,



例如datetimepickerA.value = 21:00和datetimepickerB.value = 02.00(次日02.00因为我的区域设置印度尼西亚)



我希望结果间隔时间为21:00到02:00 = 300分钟





希望你帮助

how to sum minute with 2 time with different day,

for example datetimepickerA.value = 21:00 and datetimepickerB.value =02.00 (02.00 next day because my regional setting Indonesia)

and i hope result interval 21:00 to 02:00 = 300 minutes


hope you help

推荐答案

如果DateTimePicker A和B之间的时差总是更小比 24小时,这样做:

If the time-difference between DateTimePicker A and B will always be smaller than 24 hours then this will do:
Dim diffMinutes As Int32 = (dtpB.TimeOfDay - dtpA.TimeOfDay).TotalMinutes
if diffMinutes < 0 then
    diffMinutes += 24 * 60
end if



如果时差可能大于或等于24小时,则必须在计算中包含日期,然后只需


If the time-difference can be greater than or equal to 24 hours you will have to include the date into the calculation and then it's simply

(dtpB.Value - dtpA.Value).TotalMinutes


只有时间不足以计算时间差异,除非你总是知道datepicker2总是会比datepicker1大一天。
Only time will not be sufficient to calculate the time difference unless you always know datepicker2 is always going to be greater than datepicker1 by a day.


这篇关于总和分钟与2次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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