Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Determining if given DateTime is older than a Hour

Determining if given DateTime is older than a Hour

Scheduled Pinned Locked Moved Visual Basic
question
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 4417354
    wrote on last edited by
    #1

    Hi All I am really struggeling with DateTime Formats. I have an incoming table of data coming in.It is constantly busy. I am writing a monitor system on this table.So what I want to do is retrieve the last entries dateTime. SELECT TOP(1) DateTime FROM TABLE ORDER BY DateTime DESC. What I want to know is: How do I determine if the DateTime I received is older than 1 Hour from DateTime.Now AND Ex How do I determine if the DateTime I received is older than 5 Minutes from DateTime.Now OR EX How do I determine if the DateTime I received is older than 1Hour.5 Minutes from DateTime.Now Thanks a million in advanced

    S L A 3 Replies Last reply
    0
    • U User 4417354

      Hi All I am really struggeling with DateTime Formats. I have an incoming table of data coming in.It is constantly busy. I am writing a monitor system on this table.So what I want to do is retrieve the last entries dateTime. SELECT TOP(1) DateTime FROM TABLE ORDER BY DateTime DESC. What I want to know is: How do I determine if the DateTime I received is older than 1 Hour from DateTime.Now AND Ex How do I determine if the DateTime I received is older than 5 Minutes from DateTime.Now OR EX How do I determine if the DateTime I received is older than 1Hour.5 Minutes from DateTime.Now Thanks a million in advanced

      S Offline
      S Offline
      Scubapro
      wrote on last edited by
      #2

      Take a look at: http://www.c-sharpcorner.com/UploadFile/mahesh/TwoDatesDifference08052005152233PM/TwoDatesDifference.aspx?ArticleID=7e45df46-b52a-4b48-b987-2d53201234a6

      1 Reply Last reply
      0
      • U User 4417354

        Hi All I am really struggeling with DateTime Formats. I have an incoming table of data coming in.It is constantly busy. I am writing a monitor system on this table.So what I want to do is retrieve the last entries dateTime. SELECT TOP(1) DateTime FROM TABLE ORDER BY DateTime DESC. What I want to know is: How do I determine if the DateTime I received is older than 1 Hour from DateTime.Now AND Ex How do I determine if the DateTime I received is older than 5 Minutes from DateTime.Now OR EX How do I determine if the DateTime I received is older than 1Hour.5 Minutes from DateTime.Now Thanks a million in advanced

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        it is not clear whether you want an SQL or a VB.NET approach. Maybe this article[^] gets you going. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read formatted code with indentation, so please use PRE tags for code snippets.


        I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


        1 Reply Last reply
        0
        • U User 4417354

          Hi All I am really struggeling with DateTime Formats. I have an incoming table of data coming in.It is constantly busy. I am writing a monitor system on this table.So what I want to do is retrieve the last entries dateTime. SELECT TOP(1) DateTime FROM TABLE ORDER BY DateTime DESC. What I want to know is: How do I determine if the DateTime I received is older than 1 Hour from DateTime.Now AND Ex How do I determine if the DateTime I received is older than 5 Minutes from DateTime.Now OR EX How do I determine if the DateTime I received is older than 1Hour.5 Minutes from DateTime.Now Thanks a million in advanced

          A Offline
          A Offline
          Anshul R
          wrote on last edited by
          #4

          Its very simple Use DateDiff Function First Argument is the Difference Interval See the DateInterval enumeration(has hours, seconds etc.) The Second Argument is the date you retrieve The Third Argument is the current date(Date.Now) The code will be like

          Dim hours As Long = DateDiff(DateInterval.Hour, retrievedDate, Date.Now)

          M 1 Reply Last reply
          0
          • A Anshul R

            Its very simple Use DateDiff Function First Argument is the Difference Interval See the DateInterval enumeration(has hours, seconds etc.) The Second Argument is the date you retrieve The Third Argument is the current date(Date.Now) The code will be like

            Dim hours As Long = DateDiff(DateInterval.Hour, retrievedDate, Date.Now)

            M Offline
            M Offline
            mvdcorput
            wrote on last edited by
            #5

            You can also subtract dates:

            If (RetrievedDate.Subtract(Now).TotalHours >= 1) Then
            End If

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups