Date 16 digit string need to pull data for last hour

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kommanman
    New Member
    • Apr 2020
    • 10

    Date 16 digit string need to pull data for last hour

    Trying to pull data on what happened in the previous hour but date time is 16 digit string. (ex. 202004160955408 9)
    When I use date() in criteria , nothing is returned. I can use 2020041609* but I want to make auto report without keying in criteria. any help is appreciated. thank you.
  • cactusdata
    Recognized Expert New Member
    • Aug 2007
    • 223

    #2
    You can convert that string to a true date value:

    Code:
    TrueDate: DateAdd("s", CInt(Val(Right([TextDate], 4)) / 100), CDate(Format(Left([TextDate], 12), "@@@@/@@/@@ @@:@@")))
    This you can filter on the normal way, say:

    Code:
    Between DateAdd("h", -1, Now()) and Now()

    Comment

    • kommanman
      New Member
      • Apr 2020
      • 10

      #3
      Got two errors. The first was a space after *4))_/100* which I deleted space. Then the "@@@@/@@.." was highlighted with error saying 'The expression you entered contains invalid syntax. you may have entered an operand without operator.'
      I tried changing to:
      TrueDate:DateAd d("s",CInt(Val( Right([Date],4))/100),CDate(Form at(Left([Date],12),#yyyy/mm/dd hh:mm#)))
      with and without " " around #s but got same error.
      Last edited by kommanman; Apr 20 '20, 05:52 PM. Reason: *s appeared after pasting.

      Comment

      • cactusdata
        Recognized Expert New Member
        • Aug 2007
        • 223

        #4
        It runs here, of course, with no error, returning 2020-04-16 09:55:41.

        Perhaps your provided sample differs from what you actually have.

        Comment

        • kommanman
          New Member
          • Apr 2020
          • 10

          #5
          Thank you for all your help. This finally worked after refreshing Referencing tool.
          TrueDate:DateAd d("s",CInt(Val( Right([Date],4))/100),CDate(Form at(Left([Date],12),"@@@@\/@@\/@@ @@\:@@")))
          Last edited by kommanman; Apr 21 '20, 09:05 PM. Reason: When I paste into reply, *s are added where spaces are in formula.

          Comment

          • cactusdata
            Recognized Expert New Member
            • Aug 2007
            • 223

            #6
            Great! Then please mark as answered.

            Comment

            Working...