A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Determine if Leap Year



 
 
Thread Tools Display Modes
  #1  
Old July 23rd, 2009, 08:09 PM posted to microsoft.public.access.forms
cp2599
external usenet poster
 
Posts: 46
Default Determine if Leap Year

I need to know how to tell if an entered year is a leap year so that I
know whether to concatenate an 02/28/ or an 02/29/ to the end of the
month date. Any ideas?

I know leap years have to be evenly divisible by 4 but don't know how
to check the remainder. I also think there's another piece to the
equation to prevent years like 2000 from being included, but can't
remember the formula.
  #2  
Old July 23rd, 2009, 08:38 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default Determine if Leap Year

On Thu, 23 Jul 2009 12:09:48 -0700 (PDT), cp2599 wrote:

I need to know how to tell if an entered year is a leap year so that I
know whether to concatenate an 02/28/ or an 02/29/ to the end of the
month date. Any ideas?

I know leap years have to be evenly divisible by 4 but don't know how
to check the remainder. I also think there's another piece to the
equation to prevent years like 2000 from being included, but can't
remember the formula.


You really don't need to know if any particular year is a leap year.
Access knows.
One way to find out is to set a date datatype field to 2/29/Year on
your data entry form.
If that date is not a valid date, Access will give you an error. Trap
the error and reset the date to 2/28/Year.

You could also set a control to
=DateSerial(TheYear,3,0)
which will return either 2/28/year or 2/29/year, depending upon
whether that year is a leap year.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old July 23rd, 2009, 09:05 PM posted to microsoft.public.access.forms
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Determine if Leap Year

IIF(Year(Date()) Mod 4 0, "Leap Year", "Not Leap Year")
--
Build a little, test a little.


"cp2599" wrote:

I need to know how to tell if an entered year is a leap year so that I
know whether to concatenate an 02/28/ or an 02/29/ to the end of the
month date. Any ideas?

I know leap years have to be evenly divisible by 4 but don't know how
to check the remainder. I also think there's another piece to the
equation to prevent years like 2000 from being included, but can't
remember the formula.

  #4  
Old July 23rd, 2009, 09:13 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Determine if Leap Year

Not quite. For example, 1900 wasn't a leap year, nor will 2100 be one, yet
they're both divisible by 4.

IIf(Day(DateSerial(Year(Date()), 3, 0)) = 29, "Leap Year", "Not Leap Year")

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


"KARL DEWEY" wrote in message
...
IIF(Year(Date()) Mod 4 0, "Leap Year", "Not Leap Year")
--
Build a little, test a little.


"cp2599" wrote:

I need to know how to tell if an entered year is a leap year so that I
know whether to concatenate an 02/28/ or an 02/29/ to the end of the
month date. Any ideas?

I know leap years have to be evenly divisible by 4 but don't know how
to check the remainder. I also think there's another piece to the
equation to prevent years like 2000 from being included, but can't
remember the formula.



  #5  
Old July 23rd, 2009, 09:22 PM posted to microsoft.public.access.forms
cp2599
external usenet poster
 
Posts: 46
Default Determine if Leap Year

On Jul 23, 3:38*pm, fredg wrote:
On Thu, 23 Jul 2009 12:09:48 -0700 (PDT), cp2599 wrote:
I need to know how to tell if an entered year is a leap year so that I
know whether to concatenate an 02/28/ or an 02/29/ to the end of the
month date. *Any ideas?


I know leap years have to be evenly divisible by 4 but don't know how
to check the remainder. *I also think there's another piece to the
equation to prevent years like 2000 from being included, but can't
remember the formula.


You really don't need to know if any particular year is a leap year.
Access knows.
One way to find out is to set a date datatype field to 2/29/Year on
your data entry form.
If that date is not a valid date, Access will give you an error. Trap
the error and reset the date to 2/28/Year.

You could also set a control to
=DateSerial(TheYear,3,0)
which will return either 2/28/year or 2/29/year, depending upon
whether that year is a leap year.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


What do you mean by trapping the error?
  #6  
Old July 23rd, 2009, 09:23 PM posted to microsoft.public.access.forms
cp2599
external usenet poster
 
Posts: 46
Default Determine if Leap Year

On Jul 23, 4:05*pm, KARL DEWEY
wrote:
* *IIF(Year(Date()) Mod 4 0, "Leap Year", "Not Leap Year")
--
Build a little, test a little.



"cp2599" wrote:
I need to know how to tell if an entered year is a leap year so that I
know whether to concatenate an 02/28/ or an 02/29/ to the end of the
month date. *Any ideas?


I know leap years have to be evenly divisible by 4 but don't know how
to check the remainder. *I also think there's another piece to the
equation to prevent years like 2000 from being included, but can't
remember the formula.- Hide quoted text -


- Show quoted text -


Thank you ... do you know the second half of the leap year edit?
  #7  
Old July 23rd, 2009, 09:45 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default Determine if Leap Year

On Thu, 23 Jul 2009 13:23:43 -0700 (PDT), cp2599 wrote:

On Jul 23, 4:05*pm, KARL DEWEY
wrote:
* *IIF(Year(Date()) Mod 4 0, "Leap Year", "Not Leap Year")
--
Build a little, test a little.



"cp2599" wrote:
I need to know how to tell if an entered year is a leap year so that I
know whether to concatenate an 02/28/ or an 02/29/ to the end of the
month date. *Any ideas?


I know leap years have to be evenly divisible by 4 but don't know how
to check the remainder. *I also think there's another piece to the
equation to prevent years like 2000 from being included, but can't
remember the formula.- Hide quoted text -


- Show quoted text -


Thank you ... do you know the second half of the leap year edit?


"do you know the second half of the leap year edit"
What do you mean by that part?

Perhaps this ... If Year is divisible by 4 or if a Century Year is
divisible by 400 (without a remainder) it is a leap year.

1996/4 = 499 (Leap Year
1998/4 = 499.5 (Not a leap year)
Or Century years
1900/400 = 4.75 (Not a leap year)
2000/400 = 5 (Leap Year)
2100/400=5.25 (Not a leap year)
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #8  
Old July 23rd, 2009, 10:15 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default Determine if Leap Year

On Thu, 23 Jul 2009 13:22:53 -0700 (PDT), cp2599 wrote:

On Jul 23, 3:38*pm, fredg wrote:
On Thu, 23 Jul 2009 12:09:48 -0700 (PDT), cp2599 wrote:
I need to know how to tell if an entered year is a leap year so that I
know whether to concatenate an 02/28/ or an 02/29/ to the end of the
month date. *Any ideas?


I know leap years have to be evenly divisible by 4 but don't know how
to check the remainder. *I also think there's another piece to the
equation to prevent years like 2000 from being included, but can't
remember the formula.


You really don't need to know if any particular year is a leap year.
Access knows.
One way to find out is to set a date datatype field to 2/29/Year on
your data entry form.
If that date is not a valid date, Access will give you an error. Trap
the error and reset the date to 2/28/Year.

You could also set a control to
=DateSerial(TheYear,3,0)
which will return either 2/28/year or 2/29/year, depending upon
whether that year is a leap year.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


What do you mean by trapping the error?



Look up "Error Trapping" in VBA help.
For example, entering an invalid date in a Date datatype control on a
form raises error #2113.
You can trap that error in the code's Error Handling.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #9  
Old July 23rd, 2009, 10:17 PM posted to microsoft.public.access.forms
cp2599
external usenet poster
 
Posts: 46
Default Determine if Leap Year

On Jul 23, 4:13*pm, "Douglas J. Steele"
wrote:
Not quite. For example, 1900 wasn't a leap year, nor will 2100 be one, yet
they're both divisible by 4.

IIf(Day(DateSerial(Year(Date()), 3, 0)) = 29, "Leap Year", "Not Leap Year")

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

"KARL DEWEY" wrote in message

...



* IIF(Year(Date()) Mod 4 0, "Leap Year", "Not Leap Year")
--
Build a little, test a little.


"cp2599" wrote:


I need to know how to tell if an entered year is a leap year so that I
know whether to concatenate an 02/28/ or an 02/29/ to the end of the
month date. *Any ideas?


I know leap years have to be evenly divisible by 4 but don't know how
to check the remainder. *I also think there's another piece to the
equation to prevent years like 2000 from being included, but can't
remember the formula.- Hide quoted text -


- Show quoted text -


The DateSerial function returns 2/28/2009 which is correct, but the
Day function returns 30 instead of 28. Any ideas as to why?
IIF (Day(DateSerial(Me.dtmYear,3,0)) = 29, "Leap Year", "No Leap Year"
  #10  
Old July 23rd, 2009, 10:27 PM posted to microsoft.public.access.forms
cp2599
external usenet poster
 
Posts: 46
Default Determine if Leap Year

On Jul 23, 5:15*pm, fredg wrote:
On Thu, 23 Jul 2009 13:22:53 -0700 (PDT), cp2599 wrote:
On Jul 23, 3:38*pm, fredg wrote:
On Thu, 23 Jul 2009 12:09:48 -0700 (PDT), cp2599 wrote:
I need to know how to tell if an entered year is a leap year so that I
know whether to concatenate an 02/28/ or an 02/29/ to the end of the
month date. *Any ideas?


I know leap years have to be evenly divisible by 4 but don't know how
to check the remainder. *I also think there's another piece to the
equation to prevent years like 2000 from being included, but can't
remember the formula.


You really don't need to know if any particular year is a leap year.
Access knows.
One way to find out is to set a date datatype field to 2/29/Year on
your data entry form.
If that date is not a valid date, Access will give you an error. Trap
the error and reset the date to 2/28/Year.


You could also set a control to
=DateSerial(TheYear,3,0)
which will return either 2/28/year or 2/29/year, depending upon
whether that year is a leap year.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


What do you mean by trapping the error?


Look up "Error Trapping" in VBA help.
For example, entering an invalid date in a Date datatype control on a
form raises error #2113.
You can trap that error in the code's Error Handling.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail- Hide quoted text -

- Show quoted text -


Thank you.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:13 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.