WHERE clause problem

  • Thread starter Thread starter joave
  • Start date Start date
J

joave

Hi:

I am trying to use a data field that has a space, but the WHERE clause
doesn't like it - it gives me a . When I use the field without the space (and
change the field name in the table) it works fine. I need a way to do this as
the field name HAS to have a space. None of these work:

WHERE Month(Created Date)= 3 AND Year(Created Date) = 2009
WHERE Month('Created Date')= 3 AND Year('Created Date') = 2009
WHERE Month("Created Date")= 3 AND Year("Created Date") = 2009

Thank you in advance for your help!
 
That's why spaces aint good.
Use this --
WHERE Month([Created Date])= 3 AND Year([Created Date]) = 2009
or
WHERE Format([Created Date], "yyyymm")= "200903"
 
joave said:
I am trying to use a data field that has a space, but the WHERE clause
doesn't like it - it gives me a . When I use the field without the space (and
change the field name in the table) it works fine. I need a way to do this as
the field name HAS to have a space. None of these work:

WHERE Month(Created Date)= 3 AND Year(Created Date) = 2009
WHERE Month('Created Date')= 3 AND Year('Created Date') = 2009
WHERE Month("Created Date")= 3 AND Year("Created Date") = 2009


Any name that contains a space (or any other
non-alphanumeric) character must be enclosed in [ ]

WHERE Month([Created Date])= 3 AND Year([Created Date]) =
2009

Note that a field (or any other) name never "has to have" a
space. If you think it does, you are doing something odd
because users should never see names. And if users can not
see the names, then who besides the programmer (you?) cares
what a name looks like.
 
Unfortunately it actually HAS to have a space - you see, I am importing data
from an Excel source that I have no control of :) We all have our reasons.....

Thank you,

Dave

Marshall Barton said:
joave said:
I am trying to use a data field that has a space, but the WHERE clause
doesn't like it - it gives me a . When I use the field without the space (and
change the field name in the table) it works fine. I need a way to do this as
the field name HAS to have a space. None of these work:

WHERE Month(Created Date)= 3 AND Year(Created Date) = 2009
WHERE Month('Created Date')= 3 AND Year('Created Date') = 2009
WHERE Month("Created Date")= 3 AND Year("Created Date") = 2009


Any name that contains a space (or any other
non-alphanumeric) character must be enclosed in [ ]

WHERE Month([Created Date])= 3 AND Year([Created Date]) =
2009

Note that a field (or any other) name never "has to have" a
space. If you think it does, you are doing something odd
because users should never see names. And if users can not
see the names, then who besides the programmer (you?) cares
what a name looks like.
 
joave said:
Unfortunately it actually HAS to have a space - you see, I am importing data
from an Excel source that I have no control of :) We all have our reasons.....


Thre are ways around that, but it's probably not worth
fooling with now that you know about using [ ]
 
Back
Top