Solved

Function to find last 6 month from the current date

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

816 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

10 Experts available now in Live!

Get 1:1 Help Now