ibmfreak
03-11-2010, 02:46 AM
Hi there,
I am presently building a query to get the figures for the previous day. I am using Date()-1 as a where conditional statement. However I want exclude weekends so that it shows the data for say Friday if somebody clicked to get a report on monday.Thanks in advance.
vbaInet
03-11-2010, 02:50 AM
... AND (WeekDay([Date_Field]) <> vbSaturday AND WeekDay([Date_Field]) <> vbSunday)
Something like that ^^^
ibmfreak
03-11-2010, 03:01 AM
Hey thanks vba for the quick reply I will try that and post the outcome.
vbaInet
03-11-2010, 03:07 AM
Actually, if it's a query the Weekday() function returns numbers 1 to 7. So check against 1 for Sunday and 7 for Saturday.
You may also want to try WeekDayName() which returns the full name of the day.
ibmfreak
03-11-2010, 04:06 AM
Could you frame if for me please. So if it was a select statement
Select * from patterns
where weekday() .....
vbaInet
03-11-2010, 04:12 AM
... AND WeekdayName(WeekDay([Date_Field])) <> 'Saturday' AND WeekdayName(WeekDay([Date_Field])) <> 'Sunday')
From your responses and posts I would have thought this would be trivial for you to include in your SELECT statement?:) Have a look at this link (example 3):
http://www.techonthenet.com/sql/where.php
I've amended the statement.
raskew
03-11-2010, 12:54 PM
Hi -
Try playing with this from the debug window, changing pdate() to illustrate various weekdays:
pdate = date()
? dateadd("d", IIf(WeekDay(pDate) < 3, -3, -1), date())
HTH - Bob