Results 1 to 3 of 3
  1. #1
    jfalbo is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2019
    Posts
    1

    query data from the previous day from a certain time

    I am new to Access and I am trying to query data from the night shift guys. I'm trying to pull data from the previous days starting at 6:00PM to 6:00AM the next day.

    any help would be greatly appreciated


  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Try:

    Between Date()-1 & " 18:00:00 " And Date() & " 06:00:00"

    as the criteria in your date field.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    You can use the fact that dates are stored as double numbers and you want a quarter of a day back and forward...

    Code:
    SELECT *
    FROM TableName
    WHERE CDbl(DateField) Between CDbl(Date()-0.25) And CDbl(Date()+0.25);
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

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

Similar Threads

  1. Replies: 6
    Last Post: 08-17-2016, 07:13 AM
  2. Replies: 2
    Last Post: 06-30-2016, 08:01 AM
  3. Replies: 3
    Last Post: 07-15-2015, 12:01 PM
  4. Previous Year Data Query Expression
    By NotReese in forum Queries
    Replies: 4
    Last Post: 11-22-2013, 04:54 PM
  5. Query to use previous row's data ?
    By amrut in forum Queries
    Replies: 1
    Last Post: 07-25-2012, 06:20 AM

Tags for this Thread

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