DatePart in Parameter Query

P

pjscott

I have a parameter query that queries the month and on a day of the month
range. I’m using the following in the query:

WHERE (((DatePart("m",[Doh]))=[Enter a Month]) AND ((DatePart("d",[Doh]))
Between [Enter a start day] And [Enter an ending day])

When I run the query and choose a day between 1 and 15 only days with a 1
display. In other words days between 2 and 9 do not display.

What am I doing wrong?

Thanks,

Paul
 
O

Ofer Cohen

That usually happen when the condition is on a text value, so 2 is actually
higher then 15

Try:
WHERE DatePart("m",[Doh])=[Enter a Month]) AND Val(DatePart("d",[Doh]))
Between Val([Enter a start day]) And Val([Enter an ending day])

Turning the text into number
 
P

pjscott

I got an error when I tried to use the val(DatePart("d",[Doh])).

I did get it to run fine by just using the val in the Between statement.

Thanks Ofer for the help and have a good day.


Ofer Cohen said:
That usually happen when the condition is on a text value, so 2 is actually
higher then 15

Try:
WHERE DatePart("m",[Doh])=[Enter a Month]) AND Val(DatePart("d",[Doh]))
Between Val([Enter a start day]) And Val([Enter an ending day])

Turning the text into number

--
Good Luck
BS"D


pjscott said:
I have a parameter query that queries the month and on a day of the month
range. I’m using the following in the query:

WHERE (((DatePart("m",[Doh]))=[Enter a Month]) AND ((DatePart("d",[Doh]))
Between [Enter a start day] And [Enter an ending day])

When I run the query and choose a day between 1 and 15 only days with a 1
display. In other words days between 2 and 9 do not display.

What am I doing wrong?

Thanks,

Paul
 

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