[AccessD] Six Month Review

Gustav Brock Gustav at cactus.dk
Fri Feb 2 05:18:00 CST 2007


Hi Andy (and Drew)

That's not odd. You ask for two different things.

datDate = #8/31/2007#

datNext = DateAdd("m", 6, datDate)
This will add 6 months to 2007-08-31. As there is no later day in February this year than 29, it returns 2008-02-29.

datNext = DateSerial(Year(datDate), Month(datDate) + 6, Day(datDate))
This will build datNext from year-month 2007-08, add 6 months giving 2008-02 and then add 31 days to 2008-02-00 (which is the last day of Jan.). As the day count of 2008-02 is only 29, 2 days will fall in the next month giving 2008-03-02.

It's important to distinguish between the two functions. DateAdd() does what humans think, while DateSerial takes a more mathematical approach. 
This might light a second thought for Drew, as DateSerial is capable of turning most "invalid" dates - like 2008-02-31 - into something meaningful.

/gustav

>>> andy at minstersystems.co.uk 01-02-2007 17:52 >>>
That's odd because here in the UK DateSerial takes year, month, day! How can
that be?

Also DateSerial and DateAdd give differing results when handling month-end
situations. Add 6 months to the last day of August 2007 and DateAdd gives
the last day of Feb 2008, whereas DateSerial gives 1st March. You'd need to
be aware if that's significant.


--
Andy Lacey
http://www.minstersystems.co.uk 




--------- Original Message --------
From: "Access Developers discussion and problem solving"
<accessd at databaseadvisors.com>
To: "Access Developers discussion and problem solving"
<accessd at databaseadvisors.com>
Subject: Re: [AccessD] Six Month Review
Date: 01/02/07 16:41


I doubt it. I like the DateSerial method because if I am building a date, I
don't have to worry abut the format of a date, or international standard.
DateSerial is always month, year, day.

Just a personal quirk, I guess.

Drew

-----Original Message-----
From: Susan Harkins [mailto:ssharkins at setel.com] 
Sent: Thursday, February 01, 2007 10:31 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Six Month Review

Why? Is it superior to the shorter expression in some way?

Susan H.

My personal preference is the DateSerial function:

DateNxtReview=DateSerial(Month(DateReview)+6,Year(DateReview),
Day(DateReview))





More information about the AccessD mailing list