Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / July 2006

Tip: Looking for answers? Try searching our database.

Date Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stefan - 19 Jul 2006 09:16 GMT
I would like to create a filter in my query that returns all days in a month  
from 2 months ago.

Example.  it is July so I want to return all values with any date in May
only.  In August I want to return all values for the month of june only.  In
September I want to return the values from July only etc...
Signature

Any Ideas?

Thanks in advance
Stefan

John Spencer - 19 Jul 2006 12:19 GMT
Assumption:
Your date field contains just the date and no associated time.

Under your date field use criteria like

Between DateSerial(Year(Date()),Month(Date())-2,1) and
DateSerial(Year(Date()),Month(Date())-1,0)

If your date field also contains a time (other than midnight)
YourDateField >= DateSerial(Year(Date()),Month(Date())-2,1) and
YourDateField <DateSerial(Year(Date()),Month(Date())-1,1)

>I would like to create a filter in my query that returns all days in a
>month
[quoted text clipped - 4 lines]
> In
> September I want to return the values from July only etc...
Stefan - 19 Jul 2006 19:14 GMT
Thanks for the help

can you explain the syntax of that statement for my future use.

I understand dateserial(year,month,day)

Does the last zero represent that last day of any month?
Signature

Thanks in advance
Stefan

> Assumption:
> Your date field contains just the date and no associated time.
[quoted text clipped - 16 lines]
> > In
> > September I want to return the values from July only etc...
John Spencer - 19 Jul 2006 20:26 GMT
The Zero Day of any month is the last day of the prior month.  Another way
to look at it is

DateSerial(Year, Month, 1) -1

Or
DateSerial(Year, Month, 1-1)

The dateserial function is good about adjusting when you put in negative
numbers, etc.
DateSerial(2006,1-12,1) Will return 1-1-2005  the same as
DateSerial(2006,-11,1)

If you put in a year number that is 1 or 2 digits, then DateSerial uses the
year cutoff to calculate the century.

> Thanks for the help
>
[quoted text clipped - 26 lines]
>> > In
>> > September I want to return the values from July only etc...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.