Dates confuzzle me....

Swift_74d

Board Regular
Joined
Aug 19, 2009
Messages
148
Slowly getting a grasp on access, but dates still throw me for a loop. I'm trying to filter a query by a field called "TodaysDate". The query is triggered by a form in which the user inputs two vital parts of the filter; "Year" and "Month". I need the query to show all entrys between 1/1/"year" and "month"/31/"year" but i keep getting a formating error no matter how i try.

I know this should be simple, but i just cant get the formating correct.
If it helps the "TodaysDate" has an imput mask of 99/99/0000;0;_
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
When using dates in the criteria of a query, the dates need to be surrounded by # signs, ie. Today's date would appear in the criteria as #5/10/2010# using US date convention

Alan
 
Upvote 0
Okay, first up - the input mask is irrelevant here. Anyway, it would be BEST if you could build a form for them to select the year and month but with parameter prompts it becomes a little more of a pain for the user, especially if they mistype something they will have to start over and type everything again.

You might be able to use:

Between DateSerial([Enter Year], 1, 1) And DateSerial([Enter Year], [Enter Month] + 1, 0)

Not all months have 31 days so you need to get the last day of the month and that is what the month plus one and using day zero (0) does in the DateSerial function.
 
Upvote 0
Thank you, i kept trying to concatenate the variable into something usable but date serial makes a huge difference.
 
Upvote 0

Forum statistics

Threads
1,224,604
Messages
6,179,857
Members
452,948
Latest member
UsmanAli786

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