[AccessD] Month problem

Heenan, Lambert Lambert.Heenan at AIG.com
Mon Jan 3 15:17:06 CST 2005


It's not really a function, but rather an expression that uses two built-in
access functions.

Month() of course returns the month number of a date, and  Date() returns
the current date. No surprises there.

The crucial thing is that the Month() function just returns a simple integer
*number*, so today (and for the next 28 days) the result of the expression
is going to be zero as 1-1 = 0 : amazing!!!

To get an actual month number of 'last month' you should use the DateAdd()
function, like this

Month(DateAdd("m",-1,Date()))


HTH

Lambert

> -----Original Message-----
> From:	accessd-bounces at databaseadvisors.com
> [SMTP:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup, Chester A
> Sent:	Monday, January 03, 2005 3:52 PM
> To:	accessd at databaseadvisors.com
> Subject:	[AccessD] Month problem
> 
> Why does the following function return 0 rather than 12? Is there a
> better way to do this?
> Month(Date())-1
> 
> Chester Kaup
> Information Management Technician
> IT-MidContinent/MidContinent Business Unit
> CTN 8-687-7415  
> Outside 432-687-7415
> 
> No trees were killed in the sending of this message. However a large
> number of electrons were terribly inconvenienced. 
> 
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com



More information about the AccessD mailing list