[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Convert to Hour/minute textbox and compare

Posted on 2016-11-23
3
Medium Priority
?
152 Views
Last Modified: 2016-11-23
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
0
Comment
Question by:rflorencio
  • 2
3 Comments
 
LVL 54

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 1000 total points
ID: 41899001
Hi,

pls try

refTime = CDate(ReferenceTime.Text)

Open in new window

Regards
0
 
LVL 37

Accepted Solution

by:
Pawan Kumar earned 1000 total points
ID: 41899252
Try this..

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"))

        If ActualTime >= RefTime Then
            Output = "ActualTime is Greater"
        ElseIf ActualTime = RefTime Then
            Output = "Equal"
        Else
            Output = "RefTime is Greater"
        End If

        Console.WriteLine(Output)

    End Sub

Open in new window

0
 
LVL 37

Expert Comment

by:Pawan Kumar
ID: 41899261
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

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question