Solved

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

Posted on 2003-10-29
7
274 Views
Last Modified: 2006-11-17
Hello,

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!
0
Comment
Question by:smieth
7 Comments
 
LVL 6

Expert Comment

by:lausz
Comment Utility
If you are using sql server ..

create proc test (@datex datetime)
as

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

0
 

Author Comment

by:smieth
Comment Utility
Sorry - I should have included that information.  I'm using Access 2000.
0
 
LVL 8

Expert Comment

by:Benjamin_Luk
Comment Utility
Try this:

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

This will help you

Regards

Ben
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 8

Expert Comment

by:Benjamin_Luk
Comment Utility
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

Regards

Ben
0
 

Author Comment

by:smieth
Comment Utility
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.


Thanks,

Susan
0
 
LVL 1

Accepted Solution

by:
Mustak_Shaikh earned 125 total points
Comment Utility
select datediff("h","01/" & month(@dateparm) & "/" & year(@dateparm),myfield)
 from myTable

I think that is the thing which u r looking for.
Regards,
Mustak_Shaikh
0
 

Author Comment

by:smieth
Comment Utility
Thanks!  Your formula got me back on track.  I used a modified version and it worked perfectly.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Database tuning – How to start and what to tune. This question is frequently asked by many people, both online and offline. There is no hard and fast rule-of-thumb for performance tuning, however, before beginning the tuning process one should a…
I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now