Solved

Function to find last 6 month from the current date

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

867 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