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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 Dateparts in 1 query

Status
Not open for further replies.

SDS100UK

MIS
Jul 15, 2001
185
GB
Hi,

I have a query which selects yesterdays information for a report. Which is fine for most days of the week. But on a Monday it has to select the data not for yesterday but for Saturday AND Friday.

How can I say if Datepart("d",[date]) =2 then select -2 AND -3 days ago, otherwise just select -1 day ago.

Many thanks in advance

Steven
 

Use the IIf function.

WHERE table.datecol = IIf(Weekday(date())=2, dateadd("d",-2,date()), dateadd("d",-1,date()))
OR table.datecol = IIf(Weekday(date())=2, dateadd("d",-3,date()), dateadd("d",-1,date()))
Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top