Specific Querie Criteria

A

antonio

I have a query thats display criteria is Date(). Is is
possible to place "If" conditions on the query? I would
like the querie to continue to display information
entered the previous day until 3 AM. At 3 AM I would like
the query would only display Date().

Example:
If Current Time is Between 3:00:00 AM And 11:59:00 PM
Criteria is Date().
If Current Time is Between 12:00:00 AM And 2:59:00 AM
Criteria is DateDiff("d", 1,[TodaysDate])

TIA
 
M

[MVP] S.Clark

Since I don't know your exact data, here is an example using the Northwind
Orders table.

SELECT Orders.*, Year([OrderDate]) AS Expr1
FROM Orders
WHERE (((Year([OrderDate]))=IIf(Time() Between #12/30/1899 3:0:0# And
#12/30/1899 11:59:59#,1996,1997)));

The difference is that this example select data from a particular year,
based on the current time of day.


--
HTH,

Steve Clark, Access MVP
FMS, Inc.
Professional Solutions Group
http://www.FMSInc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Is your Access database too slow?
Are you ready to upgrade to SQL Server?
Contact us for optimization and/or upsizing!
http://www.FMSInc.com/consulting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
A

Antonio

I am in no way proficient with expressions so I am having
problems adapting the example you provided to what I have
here. I am going to provide some more details in the
hopes that you can help...here goes.
Here are the components involved.
tblStorage
qryStorageList
frmStorageList
qryStorageList is used to display data on frmStorageList
from tblStorage. This form has 7 seperate datafields. One
of the fiels is called "DutyDate". It is a date/time
field that stores the day the entries are entered into
the database. In qryStorageList the criteria box in the
design view contains "Date()" which displays only that
days entries. The problem is there are folks here in the
office who work until 1 or 2 AM. If they make their
entries after 12:00:00 AM they change the duty date to
the pervious day. However, the form does not show their
entries because it is technically the day after. I want
it to continue to show the previous Duty Days entries
until 4:00 AM.
TIA
-----Original Message-----
Since I don't know your exact data, here is an example using the Northwind
Orders table.

SELECT Orders.*, Year([OrderDate]) AS Expr1
FROM Orders
WHERE (((Year([OrderDate]))=IIf(Time() Between #12/30/1899 3:0:0# And
#12/30/1899 11:59:59#,1996,1997)));

The difference is that this example select data from a particular year,
based on the current time of day.


--
HTH,

Steve Clark, Access MVP
FMS, Inc.
Professional Solutions Group
http://www.FMSInc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Is your Access database too slow?
Are you ready to upgrade to SQL Server?
Contact us for optimization and/or upsizing!
http://www.FMSInc.com/consulting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

antonio said:
I have a query thats display criteria is Date(). Is is
possible to place "If" conditions on the query? I would
like the querie to continue to display information
entered the previous day until 3 AM. At 3 AM I would like
the query would only display Date().

Example:
If Current Time is Between 3:00:00 AM And 11:59:00 PM
Criteria is Date().
If Current Time is Between 12:00:00 AM And 2:59:00 AM
Criteria is DateDiff("d", 1,[TodaysDate])

TIA


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top