?
Solved

Convert to Hour/minute textbox and compare

Posted on 2016-11-23
3
Medium Priority
?
138 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

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 32

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 32

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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

650 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