Query

pratlin

New Member
Joined
Apr 28, 2018
Messages
4
[h=1]I am creating a library database system which contains a table called "loan". The loan table contains the book id, borrower, and date/time. How would I create a query to show me the books that were loaned between yesterday's 5pm and today's 9am?[/h]
 

Some videos you may like

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,483
Office Version
365
Platform
Windows
Welcome to the Board!

The key thing to understand is how Access and Excel store dates. They store them as numbers, specifically the number of days since 1/0/1900. And time is just the fraction of a day. So 9:00 AM could be represented by 9/24.

So, to get a date/time range between 5:00 PM the previous day and 9:00 AM today, you could use this as the Criteria in your Date field in your Query:
Code:
Between (Date()-(7/24)) And (Date()+(9/24))
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,483
Office Version
365
Platform
Windows
You are welcome!:)
 

Watch MrExcel Video

Forum statistics

Threads
1,100,182
Messages
5,473,001
Members
406,843
Latest member
David_Welland

This Week's Hot Topics

Top