简体   繁体   中英

Ms-Access SQL Query

I need some guidance on how to write a query in Ms-Access which will pull all the records based on the PublishedDate but with-in the expiry date. For instance, my table carries 3 columns EventTitle, PublishDate, ExpiryDate with values Title1, 2/22/2012, 3/28/2012.

Now the 1st record will only appear on 22-Feb-2012 until 28-Mar-2012. The query which I used drops the record once the current date changes from 22-Feb to 23-Feb.

I tried using the below script

SELECT top 1 Title, ExpiryDate 
FROM Table1 
WHERE (((PublishDate)=Date() 
Or (PublishDate)<=[ExpiryDate]) 
AND ((ExpiryDate)>=Date())) 
ORDER BY ExpiryDate ASC

Sounds like you want this:

SELECT top 1 Title, ExpiryDate  
FROM Table1  
WHERE PublishDate<=Date() 
AND ExpiryDate>=Date() 
ORDER BY ExpiryDate ASC 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM