How ASP queries all records from the previous week in an Access database

Source: Internet
Author: User
Last week (within seven days):
SELECT * from Art where [today] between DATEADD ("WW", -1,now ()) and now ()
Last week (from Monday to Sunday):
SELECT * from Art where [today] between DATEADD ("D",-weekday (Now ()) -5,now ()) and DateAdd ("D",-weekday (now)) +1,now ())
Last month (today to today):
SELECT * from Art where [today] between DateAdd ("M", -1,now ()) and now ()
Last month (1th to the last day):
SELECT * from Art where [now] between dateserial (today), Month (now ()) -1,1) and DateSerial (now), Month (now ()), 1-1



Test:
Select DATEADD ("D",-weekday (Now ()) -5,now ()) Select DATEADD ("D",-weekday (Now ()) +1,now ())
These two are not the dates of the previous Monday and the Sunday, and if so, that is, your table does not have the data that meets the criteria.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.