From: MJ on
I have a database that triggers a table archive piece when the end of the
month occurs. In the case of a leap year, I think that in the case of
February the way it is currently written the actions are done on both Feb 28
and 29:

If ((Format(date, "dd") = "28") And (Format(date, "mmm") = "Feb")) Or _
((Format(date, "dd") = "29") And (Format(date, "mmm") = "Feb")) Then


Is there a way that I can check to see if this is a leap year or not, then
do the appropriate check for 28 or 29?

--

MJ
From: Douglas J. Steele on
Here's a function that will tell you whether a given year's a leap year or
not:

Function IsLeapYear(YearNumber As Long) As Boolean

IsLeapYear = Day(DateSerial(YearNumber, 2, 29)) = 29

End Function

Alternatively, here's a function that will give you the last day of the
month:

Function LastDayOfMonth(YearNumber As Long, MonthNumber As Long) As Long

LastDayOfMonth = Day(YearNumber, MonthNumber + 1, 0))

End Function

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"MJ" <MJ(a)discussions.microsoft.com> wrote in message
news:65D9246B-BF28-4607-BE2C-B3E3EDC2B402(a)microsoft.com...
>I have a database that triggers a table archive piece when the end of the
> month occurs. In the case of a leap year, I think that in the case of
> February the way it is currently written the actions are done on both Feb
> 28
> and 29:
>
> If ((Format(date, "dd") = "28") And (Format(date, "mmm") = "Feb")) Or _
> ((Format(date, "dd") = "29") And (Format(date, "mmm") = "Feb"))
> Then
>
>
> Is there a way that I can check to see if this is a leap year or not, then
> do the appropriate check for 28 or 29?
>
> --
>
> MJ


From: John W. Vinson on
On Wed, 2 Jul 2008 10:34:00 -0700, MJ <MJ(a)discussions.microsoft.com> wrote:

>I have a database that triggers a table archive piece when the end of the
>month occurs. In the case of a leap year, I think that in the case of
>February the way it is currently written the actions are done on both Feb 28
>and 29:
>
> If ((Format(date, "dd") = "28") And (Format(date, "mmm") = "Feb")) Or _
> ((Format(date, "dd") = "29") And (Format(date, "mmm") = "Feb")) Then
>
>
>Is there a way that I can check to see if this is a leap year or not, then
>do the appropriate check for 28 or 29?

That's an awfully complicated way to find the last day of the month! This
expression will work to find the last day of any month in any year:

DateSerial(Year(Date()), Month(Date()) + 1, 0)

--

John W. Vinson [MVP]
 | 
Pages: 1
Prev: Pivot Chart View
Next: System.mdw error