I need a formula to return data for the month based on week ending criteria


I have a query that is based on date criteria.  For example if someone enters the date 10/12/03 it will bring all records from 1/1/2000 - 10/12/03.  I would like to create a formula so if someone enters a date, it will bring records for that month.  For example if someone enters the date 10/12/03 records will show for the month of October.

Any help would be appreciated.  Thank you!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you are using sql server ..

create proc test (@datex datetime)

select * from yourtable
where month(yourdatefield ) = month(@datex)
and year(yourdatefield ) = year(@datex)

then ..

exec test '2003-10-01' --will give you all information for this month/year

smiethAuthor Commented:
Sorry - I should have included that information.  I'm using Access 2000.
Try this:

Select * From myTable Where Format([myField],"MMM-YY") = Format ([Please Enter Date Format MM/DD/YYYY],"MMM_YY");

This will help you


Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

It should be:

Select * From myTable Where Format([myField],"MMM-YY") = Format ([Please Enter Date Format MM/DD/YYYY],"MMM-YY");

Sorry for type error


smiethAuthor Commented:
Hi there,

I don't think that I explained what I need to do correctly.  I have a query that is already based on date criteria.  I need to setup a formula within that query that will show the hours for the month selected.   So if they enter 10/30/03 for the criteria, the formula will know to bring the hours field over for those hours based on the month of October.  I hope that makes sense.


select datediff("h","01/" & month(@dateparm) & "/" & year(@dateparm),myfield)
 from myTable

I think that is the thing which u r looking for.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
smiethAuthor Commented:
Thanks!  Your formula got me back on track.  I used a modified version and it worked perfectly.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.