Query Criteria

bibstar03

New Member
Joined
Jan 30, 2003
Messages
25
I have a table which contains data on different dates. When i run a query i need to be able to show the data for that week. I can use criteria which looks like this

>1/07/04 And <7/07/04

but the dates must be entered each time. i need a way that when the query is run, the dates for that week are shown.

Thanks for any help :biggrin:

Bibstar
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I tested the following, I'm sure there are other ways but try this:

Paste the following into a new field in the query grid (put in your date field)

WeekNumber: Format([YourDate],"ww")

That expression will return the Week number, check for yourself on a calender.

Now in the criteria place the following:

Format(Now(),"ww") And Year([YourDate])=Year(Now())

The criteria is using the week number of whatever today's date ( the date query is run), plus is only returning the current year other wise you'll get other years returned.


It works let me know if you have any problems

Ziggy
 
Upvote 0

Forum statistics

Threads
1,221,618
Messages
6,160,855
Members
451,674
Latest member
TJPsmt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top