Solved

Function to find last 6 month from the current date

Posted on 2004-03-29
5
233 Views
Last Modified: 2012-05-04
Dear Experts,

I have a problem in finding the last 6 month from the current date.
example:
the last 6 month from march 2004 are
Sep '03, Okt 03, Nov 03, Dec 03, Jan '04, and Feb '04.
are there anyone could help me how to make function for this problem in access.
Please Help...

Regards,
fbachri
0
Comment
Question by:fbachri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 10702280
you could use the dateadd function

ie.  newDate = DateAdd("m",-6,now())

returns a date 6 months ago
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10702290
so to display the last 6 months (depending on what order you want, just change the loop)

dim i as byte

for i = 6 to 1 step -1
    debug.print "Date as of " & i & " months ago", dateAdd("m",i,now())
next i
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 100 total points
ID: 10702323
sorry, that should be

dateAdd("m",i*-1,now())

or you can just add the negative values in the loop (for i = -6 to -1)
0
 

Author Comment

by:fbachri
ID: 10702709
Thanks....
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10702720
eh, no worries

just to let you know, there is an alternative, good for building dates

DateSerial
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

695 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