Results 1 to 6 of 6
  1. #1
    ERB is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    6

    Sort by time only in a date/time field

    I have a column/field named [DateTaken] which contains test dates and times in the same cell. I am needing to find those with a test time less than 2:30 pm or <14:30pm.



    data looks like this:

    8/22/13 4:23 PM
    1/29/14 12:21 PM
    1/28/14 3:27 PM
    8/26/13 4:27 PM
    8/26/13 4:42 PM
    1/23/14 1:58 PM
    8/21/13 1:12 PM
    8/21/13 2:40 PM
    1/23/14 3:16 PM

    this is what I have come up with to extract the time component of data set so that I can then later, sort it by the time in a query.

    JustTime: TimeValue([YourField])

    JustTime: ("hh:mm",([DateTaken])) and or ("hh:mm",[DateTaken])

    I get either invalid operator or invalid syntax errors trying both of these.

    Any help or ideas appreciated, Thank you.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The second one completely invalid. The first should work. Did you try

    JustTime: TimeValue([DateTaken])

    If that doesn't work, what's the data type of that field? Does it contain any Null values?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ERB is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    6
    I just tried this TimeTaken: "h:mm"([DateTaken] and i get an error which I have taken a screenshot of, see below.

    The date type of the field is date/time and it is in this format : m/d/yyyy h:nn


    Also there are no Nulls in the data.



    Click image for larger version. 

Name:	screen.jpg 
Views:	6 
Size:	22.1 KB 
ID:	15818

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    That's the second format that I mentioned was completely invalid. Did you try what I suggested?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    ERB is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    6
    I see now. I though that TimeValue meant that I had to input a number value or formula in order to get it to work. Its working now. Thanks for your help pbaldy.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-13-2014, 07:23 PM
  2. Replies: 4
    Last Post: 03-06-2013, 02:32 PM
  3. Date/Time Field
    By donnan33 in forum Programming
    Replies: 2
    Last Post: 01-19-2012, 04:03 PM
  4. Replies: 12
    Last Post: 02-22-2011, 03:39 PM
  5. Replies: 6
    Last Post: 01-04-2011, 05:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums