Compile Error Using Weekday Function

  • Thread starter Thread starter GRayL
  • Start date Start date
G

GRayL

I have a simple one column table containing all the dates
for 2004. I wish to remove the weekends so to be sure I
created a simple select query before invoking a delete
query:

"Select *, var from Days2004 where
weekday(days2004.var) = 1 or weekday(days2004.var) = 7;"

I keep getting: Compile error. in query
expression 'weekday(days2004.var) = 1 or weekday
(days2004.var) = 7'

This is really ruining my weekend. I have removed and
reinstalled Access to no avail. Help
 
Hi,
Unless I'm mistaken, you can't use the function like that.
Instead, create a calculated field.
wkDay:weekday(days2004.var)

then use a criteria of 1 or 7 against that field.
 
Wait a minute, that's the same thing as you're doing!
Anyway, I just tested it out and it works fine here.
Try enclosing the argument in [] and dropping the table qualifier.
weekday([var])
 
Dan: I've tried that with the following query:

SELECT Days2004.*, Weekday([days2004].[var]) AS WkDay
FROM Days2004;

Again I get the 'compile error. in query expression
weekday(Days2004.var)'

-----Original Message-----
Hi,
Unless I'm mistaken, you can't use the function like that.
Instead, create a calculated field.
wkDay:weekday(days2004.var)

then use a criteria of 1 or 7 against that field.

--
HTH
Dan Artuso, Access MVP


"GRayL" <[email protected]> wrote in
message news:[email protected]...
 
As I replied to your other post. VAR is an SQL function. To use "Var" as a
field name you MUST enclose it in brackets as [Var].



Dan: I've tried that with the following query:

SELECT Days2004.*, Weekday([days2004].[var]) AS WkDay
FROM Days2004;

Again I get the 'compile error. in query expression
weekday(Days2004.var)'
-----Original Message-----
Hi,
Unless I'm mistaken, you can't use the function like that.
Instead, create a calculated field.
wkDay:weekday(days2004.var)

then use a criteria of 1 or 7 against that field.

--
HTH
Dan Artuso, Access MVP


"GRayL" <[email protected]> wrote in
message news:[email protected]...
 
Back
Top