DWUTKA at marlow.com
DWUTKA at marlow.com
Mon Jan 3 15:02:24 CST 2005
Because Month(Date()) is 1 (right now, since it's January. And 1-1 is 0. Now, I know you may think it should be smart enough to realize that you are 'asking' for the previous month, but the Month function is just simply returning an integer, not a number 'with meaning'. So, to do what you are trying to do, use this: Month(DateSerial(year(date),month(date)-1,day(date))) The 'inside' month(date)-1 will return a 0, just as in your original line, however, Date Serial will take the 0 as 12 (the month before), and thus you'll end up with 12-4-05 as the date returned by the DateSerial function, running that through the Month function again (the outside month function), you'll get 12, instead of 0. Hope that helps! Drew -----Original Message----- From: Kaup, Chester A [mailto:kaupca at chevrontexaco.com] Sent: Monday, January 03, 2005 2: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