?
Solved

Convert to Hour/minute textbox and compare

Posted on 2016-11-23
3
Medium Priority
?
120 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 52

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 29

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 29

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 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