Function to find last 6 month from the current date

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
fbachriAsked:
Who is Participating?
 
rockiroadsConnect With a Mentor Commented:
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
 
rockiroadsCommented:
you could use the dateadd function

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

returns a date 6 months ago
0
 
rockiroadsCommented:
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
 
fbachriAuthor Commented:
Thanks....
0
 
rockiroadsCommented:
eh, no worries

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

DateSerial
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.