Pass date to query?

J

jason

How would I pass a DATE to a query to only pick up those records which were
inserted in the last week (7 days). I assume I would only be adjusting the
WHERE clause below which works for my other parameter queries. The key field
is the Insertion_Date field. I am unsure how to phrase the condition:

PARAMETERS DateCheck;

SELECT
tblListings.Insertion_Date,
tblListings.ListingsID, tblListings.Name, tblListings.Name_Client,
tblListings.Model, tblListings.Size_ID, tblListings.Hull_Number,
tblListings.Year, tblYacht_Type.Yacht_Type, tblListings.Yacht_Type_ID,
tblListings.Original_Price, tblListings.Current_Price,
tblListings.Status_Price_Reduced, tblListings.Price_Reduction_Date,
tblListings.Location_Status_ID, tblListings.State, tblListings.Country,
tblListings.Marina, tblListings.Listing_Broker_ID,
tblListings.Listing_Broker_Comm_ID, tblListings.Selling_Broker_ID,
tblListings.Selling_Broker_Comm_ID, tblListings.Selling_Broker_VUO_ID,
tblListings.Date_viewable, tblListings.Comments, tblListings.Link,
tblListings.Closing_Date, tblListings.Source_ID, tblListings.Image1,
tblListings.Image2, tblListings.Image3, tblListings.Location_Status_ID,
tblLocation_Status.Location_Status

FROM tblLocation_Status

INNER JOIN (tblYacht_Type
INNER JOIN tblListings ON tblYacht_Type.YachtTypeID =
tblListings.Yacht_Type_ID)
ON tblLocation_Status.Location_StatusID = tblListings.Location_Status_ID


WHERE (
([DateCheck] IS NULL or tblListings.Insertion_Date=[DateCheck])
);
 
J

John Vinson

How would I pass a DATE to a query to only pick up those records which were
inserted in the last week (7 days).

Try:
WHERE (([DateCheck] IS NULL
OR tblListings.Insertion_Date BETWEEN DateAdd("ww", -1, Date()) AND
Date()))
 

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

Similar Threads


Top