Hi,
Does anyone know how to display differences between 2 times from 2 different dtpicker displaying results in HH:mm rather than just h or n? I am designing a project for friend so she can enter her start, end, and lunch time in order to calculate total weekly hours worked.
I did have a text box input way of doing until i realised that half an hour was 0.70! Any way of rescuing that way of doing it sounds good.
E.g, I have 15:00 and 17:15, I want label1.caption to display 2hrs 15mins.
Apart from the obvious attempts I have tried the following but the answer for 15:00 17:00 is 2.25
Dim minutesdiv, total1, time1hour, time2hour, total2, time1minute, time2minute, timediff As Variant
Private Sub Command1_Click( )
time1hour = DTPicker1.Hour
time1minute = DTPicker1.Minut e
time2hour = DTPicker2.Hour
time2minute = DTPicker2.Minut e
total1 = time1hour & "." & time1minute
total2 = time2hour & "." & time2minute
timediff = DateDiff("n", total1, total2)
minutesdiv = timediff / 60
Label1.Caption = minutesdiv
End Sub
I have used variant as I am new to Vb, I would change appropriatly if I can get working.
I genuinely have spent about 12 hours on this small issue.
Does anyone know how to display differences between 2 times from 2 different dtpicker displaying results in HH:mm rather than just h or n? I am designing a project for friend so she can enter her start, end, and lunch time in order to calculate total weekly hours worked.
I did have a text box input way of doing until i realised that half an hour was 0.70! Any way of rescuing that way of doing it sounds good.
E.g, I have 15:00 and 17:15, I want label1.caption to display 2hrs 15mins.
Apart from the obvious attempts I have tried the following but the answer for 15:00 17:00 is 2.25
Dim minutesdiv, total1, time1hour, time2hour, total2, time1minute, time2minute, timediff As Variant
Private Sub Command1_Click( )
time1hour = DTPicker1.Hour
time1minute = DTPicker1.Minut e
time2hour = DTPicker2.Hour
time2minute = DTPicker2.Minut e
total1 = time1hour & "." & time1minute
total2 = time2hour & "." & time2minute
timediff = DateDiff("n", total1, total2)
minutesdiv = timediff / 60
Label1.Caption = minutesdiv
End Sub
I have used variant as I am new to Vb, I would change appropriatly if I can get working.
I genuinely have spent about 12 hours on this small issue.
Comment