Click here to Skip to main content
15,881,755 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

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

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
VB
(dtpB.Value - dtpA.Value).TotalMinutes
 
Share this answer
 
v4
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900