Link to home
Start Free TrialLog in
Avatar of rp
rpFlag for Portugal

asked on

Convert to Hour/minute textbox and compare

Hi,

I have a datatable column with date/time type and extract hour:minute from:  

ActualTime = CDate(Format(Tb.Rows.Item(0)("Exit"), "HH:mm"))

And i have a textbox with a hour:minute text format :

ReferenceTime.Text= "08:30"

I need to compare if the ActualTime is bigger or not than ReferenceTime.
How can convert ReferenceTime.Text to Hour/minute format to compare.

best regards
SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or. this..

Dim Out As Integer = DateTime.Compare(ActualTime, RefTime)

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim a As DateTime = "2016/01/01 09:53"
        Dim b As DateTime = "2016/01/01 08:30"
        Dim Output As String

        Dim ActualTime As String = CDate(Format(a, "HH:mm"))
        Dim RefTime As String = CDate(Format(b, "HH:mm"))

        Dim Out As Integer = DateTime.Compare(ActualTime, RefTime)

        If Out < 0 Then
            Output = "ActualTime is Greater"
        ElseIf Out = 0 Then
            Output = "Equal"
        Else
            Output = "RefTime is Greater"
        End If

        Console.WriteLine(Output)

    End Sub

Open in new window