Click here to Skip to main content
15,920,801 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here i had displayed the status by comparing the values of two datetimepickers , how can i display the hours by comparing the time displayed in the datetimepicker.



Dim d1 As DateTime = Me.DateTimePicker2.Value
        Dim d2 As DateTime = Me.DateTimePicker3.Value
        If d2 <= d1 Then
            TextBox12.Text = " ON-TIME"
        ElseIf d2 > d1 Then
            TextBox12.Text = " DELAY"
        End If
Posted

 
Share this answer
 
To get Hour from the DateTimePicker Value use the following code :
VB
Dim _hour As Int32 = DateTimePicker1.Value.Hour

Use the following code :
VB
Dim d1 As Int32 = Me.DateTimePicker1.Value.Hour
Dim d2 As Int32 = Me.DateTimePicker2.Value.Hour
If d2 <= d1 Then
    TextBox12.Text = " ON-TIME"
ElseIf d2 > d1 Then
    TextBox12.Text = " DELAY" & (d2 - d1) & "Hours"
End If

I hope it will help you. :)
 
Share this answer
 
Comments
ANANTH P 30-Nov-11 1:06am    
hi thanks for ur reply , i tried the above coding , the time value is not changing from the datetimepicker, value 0 is returning for the above coding

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