Solved

Query DateField Return all records within a 1 month period

Posted on 2004-04-28
3
413 Views
Last Modified: 2012-05-04
I have a date field in my database, and i want to be able to run a query that will return any record for  the month i select,

is there a way to  read just the month from the datefield and return just that month

I dont want to use the between command,

date format is mm/dd/yy

I am a beginner with Access, but know my way around, just need some help.

Thanks

0
Comment
Question by:beeernpizza
3 Comments
 
LVL 6

Accepted Solution

by:
nathaniel earned 50 total points
ID: 10946076
other way around is:

Field    : Month([dateField])
Table   :
Sort     :
Show   :
Criteria: 1

to extract the month of January.
0
 

Author Comment

by:beeernpizza
ID: 10946198
This Works great just what i was looking for.

Thanks .
0
 
LVL 16

Expert Comment

by:ahmedbahgat
ID: 10946227
how about the year?

for example if you select the  month   Jan

which records you want to include records


01/01/2004


01/01/2010


so if yoy want all records by month, do you care what year, or you need to include all records with the same month period

if it is the month only and you do not care about the year, then create a form to select what month you want, remeber that access understands months as 1,2,3,4,5,6,7,8,9,10,11,12  and not Jan, Feb........

so your criteria for the month must be in numbers and not words, so if you have a textbox on your form called "MyMonth". then add a new column to your query like this

Exp: Month([MyDateField])

in front of the criteria for that new column we added, add the following:  Forms!MyForm!MyMonth

if you care about the year, then you have 2 options:

1. records within the current year
2. records with a year you select, in addition to the month

so add a new column to your query next to the one we added, it should look like:

Exp1:  Year([MyDateField])

 in front of the criteria for that new column we added, add the following:  Forms!MyForm!MyYear

and MyYear should be another textbox on your form, where you will type the year

if you want the current year only, then you do  not need to enter a year in your form but the second column we added will look like:

Exp1:  Year([MyDateField])

 in front of the criteria for that new column we added, add the following:  Year(Date())

cheers


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

895 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

12 Experts available now in Live!

Get 1:1 Help Now