Calculate expirate date taking into account leap year

  • Thread starter Thread starter dawnecia
  • Start date Start date
D

dawnecia

Given the start date, how do I calculate the expiration date while taking
into account the leap year.

Here's what I have so far using multiple fields in a query

YrNum: Year([startdate])
leapChk: [YrNum]/100-Round([YrNum]/100,0)
LeapYr: IIf([leapchk]>0,[startdate]+365,[startdate]+366)

Thanks
 
Easiest way is

DateAdd("yyyy",1,[StartDate])



John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
You can also simply check if the 60th day of the year is in February, to
know if the year to be tested is a leap year:

? 2 = Month(DataSerial( TestedYear , 1, 60 ) )



But for the OP, a simple DateAdd should simply do the job.



Vanderghast, Access MVP



raskew via AccessMonster.com said:
Hi -

For what it's worth, a leap year must be evenly divisible by 4 AND if a
millenium year (1700, 1800, 1900, 2000, etc.) evenly divisible by 400. So
1700, 1800 and 1900 were not leap years, 2000 was.

IsLeapyear = IIf(year([dteMyDate]) Mod 100 = 0, IIf(year([dteMyDate]) Mod
400
= 0, True, False), IIf(year([dteMyDate]) Mod 4 = 0, True, False))

Bob
Given the start date, how do I calculate the expiration date while taking
into account the leap year.

Here's what I have so far using multiple fields in a query

YrNum: Year([startdate])
leapChk: [YrNum]/100-Round([YrNum]/100,0)
LeapYr: IIf([leapchk]>0,[startdate]+365,[startdate]+366)

Thanks
 
IsLeapYear is easily calculated with the following expression
Month(DateSerial([YearNumber],1,60))=2

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
Hi -

For what it's worth, a leap year must be evenly divisible by 4 AND if a
millenium year (1700, 1800, 1900, 2000, etc.) evenly divisible by 400. So
1700, 1800 and 1900 were not leap years, 2000 was.

IsLeapyear = IIf(year([dteMyDate]) Mod 100 = 0, IIf(year([dteMyDate]) Mod 400
= 0, True, False), IIf(year([dteMyDate]) Mod 4 = 0, True, False))

Bob
Given the start date, how do I calculate the expiration date while taking
into account the leap year.

Here's what I have so far using multiple fields in a query

YrNum: Year([startdate])
leapChk: [YrNum]/100-Round([YrNum]/100,0)
LeapYr: IIf([leapchk]>0,[startdate]+365,[startdate]+366)

Thanks
 
.... As John wrote, it is DateSerial, not DataSerial. My typo.

Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top