How to search in a date field ?

S

SpookiePower

I have a field in my table of the type date - Long date.

I want to search the table by month and year, but I
dont know how to search in a date field using sql.

My first idea was to make a field called day, one called
month and one call year. And when I should search for
some data I would do it this way -
WHERE month = 05 AND year = 2006
But if I want to use and search the date field, how can I then do it ??
 
M

Marshall Barton

SpookiePower said:
I have a field in my table of the type date - Long date.

I want to search the table by month and year, but I
dont know how to search in a date field using sql.

My first idea was to make a field called day, one called
month and one call year. And when I should search for
some data I would do it this way -
WHERE month = 05 AND year = 2006
But if I want to use and search the date field, how can I then do it ??


Another way is to add a calculated field to the query:
Format(datefield, "mm/yyyy")
And use the criteria:
"05/2006"
 

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