Solved

Function to find last 6 month from the current date

Posted on 2004-03-29
5
228 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
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.

746 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

13 Experts available now in Live!

Get 1:1 Help Now