using a date variable in query criteria

  • Thread starter Dsperry101 via AccessMonster.com
  • Start date
D

Dsperry101 via AccessMonster.com

Hello

I want to use date variables in the criteria of a query.
When I put Between #1-1-07# and #1-30-07# it works
but if I try to use a date variable it doesn't work. In
the query by example view. The field in the database
is a string but I convert to a date using
Datevalue([work_order_received]). I want to calculate
a date like this in the Field:
dateback: datefrom: ( year(Date())-1 , 1 ,1)
dateto: (year(Date())-1,12,31)
When I try to use the variables (datefrom dateto) in the
criteria statement this doesn't work
Between datefrom and dateto
gives me invalid date format and access throws quotes
around my variables.
Any suggestions ?
 
G

Guest

This is still hard to visualize. Can you post all the actual SQL of your
query that is giving the error.
 
D

Douglas J. Steele

Dsperry101 via AccessMonster.com said:
Andy said:
This is still hard to visualize. Can you post all the actual SQL of your
query that is giving the error.
[quoted text clipped - 13 lines]
around my variables.
Any suggestions ?
Andy
I am trying to do this in query design view....

Doesn't matter. Queries are always SQL, regardless of how you created them.

To see the SQL that's been generated by Access for your question, open the
query in Design view, and select SQL View from the View menu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top