Solved

Convert to Hour/minute textbox and compare

Posted on 2016-11-23
3
36 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 48

Assisted Solution

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

pls try

refTime = CDate(ReferenceTime.Text)

Open in new window

Regards
0
 
LVL 18

Accepted Solution

by:
Pawan Kumar Khowal earned 250 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 18

Expert Comment

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now