Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

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

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
smieth
Asked:
smieth
1 Solution
 
lauszCommented:
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
 
smiethAuthor Commented:
Sorry - I should have included that information.  I'm using Access 2000.
0
 
Benjamin_LukCommented:
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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
Benjamin_LukCommented:
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
 
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.


Thanks,

Susan
0
 
Mustak_ShaikhCommented:
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
 
smiethAuthor Commented:
Thanks!  Your formula got me back on track.  I used a modified version and it worked perfectly.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Tackle projects and never again get stuck behind a technical roadblock.
Join Now