Where clause in query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to use a where clause in a query such that query would only
select Aug dates , but I'm not sure how the statement would be constructed.

Something like:

stSql= SELECT [table A] WHERE [DATE]=8/*/****
 
Try the Month() function:
strSql= "SELECT [table A].* FROM [table A] WHERE Month([table A].[DATE])
= 8;"
 
stSql= "SELECT [table A] WHERE Month([DATE]) = 8;"

Don't name anything date. Date is a reserved word in Access and doing this
can cause unexpected results.
 
Anything!? I have several tables and thus queries that have a [Date] field -
is that Okay? It seems to work, because I have tens if not hundreds of
reference too these date Fields.

--
David McKnight


Klatuu said:
stSql= "SELECT [table A] WHERE Month([DATE]) = 8;"

Don't name anything date. Date is a reserved word in Access and doing this
can cause unexpected results.

David McKnight said:
I would like to use a where clause in a query such that query would only
select Aug dates , but I'm not sure how the statement would be constructed.

Something like:

stSql= SELECT [table A] WHERE [DATE]=8/*/****
 
Yup. It's a bad move. e.g. http://support.microsoft.com/kb/209187/

There are various utilities which will search a db and change everything for
you - but I've never had to use one so can't really recommend a particular
one. Anyone?


David McKnight said:
Anything!? I have several tables and thus queries that have a [Date] field -
is that Okay? It seems to work, because I have tens if not hundreds of
reference too these date Fields.

--
David McKnight


Klatuu said:
stSql= "SELECT [table A] WHERE Month([DATE]) = 8;"

Don't name anything date. Date is a reserved word in Access and doing this
can cause unexpected results.

David McKnight said:
I would like to use a where clause in a query such that query would only
select Aug dates , but I'm not sure how the statement would be constructed.

Something like:

stSql= SELECT [table A] WHERE [DATE]=8/*/****
 
The ones I know are:

Find & Replace: http://www.rickworld.com/products.html
Speed Ferret: http://www.moshannon.com/speedferret.html
Ucora's: http://www3.bc.sympatico.ca/starthere/findandreplace/

I've used Find & Replace for years.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rob Oldfield said:
Yup. It's a bad move. e.g. http://support.microsoft.com/kb/209187/

There are various utilities which will search a db and change everything
for
you - but I've never had to use one so can't really recommend a particular
one. Anyone?


message
Anything!? I have several tables and thus queries that have a [Date] field -
is that Okay? It seems to work, because I have tens if not hundreds of
reference too these date Fields.

--
David McKnight


Klatuu said:
stSql= "SELECT [table A] WHERE Month([DATE]) = 8;"

Don't name anything date. Date is a reserved word in Access and doing this
can cause unexpected results.

:

I would like to use a where clause in a query such that query would only
select Aug dates , but I'm not sure how the statement would be constructed.

Something like:

stSql= SELECT [table A] WHERE [DATE]=8/*/****
 
I'll give these a try on a backup copy of my database - I'm interested to
see impact on performance since [data] is such a critical pat of my databse.

thanks
--
David McKnight


Douglas J. Steele said:
The ones I know are:

Find & Replace: http://www.rickworld.com/products.html
Speed Ferret: http://www.moshannon.com/speedferret.html
Ucora's: http://www3.bc.sympatico.ca/starthere/findandreplace/

I've used Find & Replace for years.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rob Oldfield said:
Yup. It's a bad move. e.g. http://support.microsoft.com/kb/209187/

There are various utilities which will search a db and change everything
for
you - but I've never had to use one so can't really recommend a particular
one. Anyone?


message
Anything!? I have several tables and thus queries that have a [Date] field -
is that Okay? It seems to work, because I have tens if not hundreds of
reference too these date Fields.

--
David McKnight


:

stSql= "SELECT [table A] WHERE Month([DATE]) = 8;"

Don't name anything date. Date is a reserved word in Access and doing this
can cause unexpected results.

:

I would like to use a where clause in a query such that query would only
select Aug dates , but I'm not sure how the statement would be constructed.

Something like:

stSql= SELECT [table A] WHERE [DATE]=8/*/****
 
David, altering the field name will not improve the performance of your
database.

What it does is avoid the cases where Access misinterprets what you meant.
Date is a reserved word in VBA (for the system date), so there are cases
where Access will use today's date instead of the value in the field, and
your progam will appear to be giving wrong results.

Renaming the field to InvoiceDate or OrderDate or whatever prevents that
ambiguity.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

David McKnight said:
I'll give these a try on a backup copy of my database - I'm interested to
see impact on performance since [data] is such a critical pat of my
databse.

thanks
--
David McKnight


Douglas J. Steele said:
The ones I know are:

Find & Replace: http://www.rickworld.com/products.html
Speed Ferret: http://www.moshannon.com/speedferret.html
Ucora's: http://www3.bc.sympatico.ca/starthere/findandreplace/

I've used Find & Replace for years.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Rob Oldfield said:
Yup. It's a bad move. e.g. http://support.microsoft.com/kb/209187/

There are various utilities which will search a db and change
everything
for
you - but I've never had to use one so can't really recommend a
particular
one. Anyone?


message
Anything!? I have several tables and thus queries that have a [Date]
field -
is that Okay? It seems to work, because I have tens if not hundreds of
reference too these date Fields.
 
Back
Top