Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Day Syntax 1

Status
Not open for further replies.
Feb 25, 2008
46
US

I am trying to run a select query on a table where the date range is 3 days if the current day is Monday and date range is 1 day if the current day is any day other than Monday

I was using this syntax:
IIf(Weekday(Date())=2,Between ((Date())-3) And ((Date())-1),Between ((Date())-1) And (((Date())-1)))

But the query returns a blank dataset.

The purpose of this query is to view records added on the previous day. On Monday it would be to view the records added on Friday, Saturday and Sunday.

Could someone please correct the syntax or suggest a better one? I need to do this as this is a repetitive daily task.

Many thanks,

Mark.

 
Code:
BETWEEN IIf(Weekday(Date())=2,Date()-3, Date()-1) AND Date()-1
 
Or even better
Code:
BETWEEN Date()-IIf(Weekday(Date())=2,3,1) AND Date()-1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top