Normal Topic Last month's name (Read 806 times)
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Last month's name
Apr 27th, 2007 at 3:36pm
Print Post Print Post  
I'm trying to date stamp a report with last month's month name and year.  I've tried several different codes.

This breaks, because I'm mixing string and integer functions:
Code
Select All
Month_and_Year = @Month$(@Date)-1 + ", " + @STR(@YEAR(@DATE)) 



This produces April, 2007 (or any current month)
Code
Select All
Month_and_Year = @Month$((@Date)-1) + ", " + @STR(@YEAR(@DATE)) 



This Produces January, 2007, and I don't know why
Code
Select All
Month_and_Year = @Month$(@Month(@Date)-1) + ", " + @STR(@YEAR(@DATE)) 



I'm stumped.
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Last month's name
Reply #1 - Apr 27th, 2007 at 4:07pm
Print Post Print Post  
Hello Scott,

Something like this should work for you

Code
Select All
Var vDate as Date

	vDate = @Date
	vDate = vDate - @Dom(vDate)
	Month_and_Year = @Month$(vDate) + ", " + @Str(@Year(vDate)) 




-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Last month's name
Reply #2 - Apr 27th, 2007 at 4:15pm
Print Post Print Post  
Thanks Ray, that works well.  I never would have figured that out.
  

**
Captain Infinity
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Last month's name
Reply #3 - Apr 27th, 2007 at 4:56pm
Print Post Print Post  
I hate to push it, but what about 2 months ago?
  

**
Captain Infinity
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Last month's name
Reply #4 - Apr 27th, 2007 at 5:06pm
Print Post Print Post  
Code
Select All
Var vDate as Date
Var vLoop as Int
Var vMonthsAgo as Int

	vDate = @Date
	vLoop = 1
	vMonthsAgo = 2

	While vLoop<= vMonthsAgo
	{
		vDate = vDate - @Dom(vDate)
		vLoop = vLoop + 1
	}
	Month_and_Year = @Month$(vDate) + ", " + @Str(@Year(vDate))  



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Infinity
Senior Member
Members
*****
Offline


Diagonally parked in a
parallel dimension

Posts: 1290
Location: Massachusetts
Joined: May 27th, 2005
Re: Last month's name
Reply #5 - Apr 27th, 2007 at 7:00pm
Print Post Print Post  
There it is!  That's fantastic.  Thank you so much Ray, that's beautiful.
  

**
Captain Infinity
Back to top
IP Logged