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. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|