Subject RE: [firebird-support] Re: Subtract Years from a Date Value in SQL
Author Louis Kleiman
You may need to watch out for one tiny situation. Basically, you may run
into an issue if your base date is 2/29/<Leap Year> and you try to go
forward 100 years to a year that isn’t a leap year. “Since 100 is divisible
by 4, it will always be a leap year.” you might say. But in some situations
this isn’t true. From www.timeanddate.com <http://www.timeanddate.com/> :

1. Every year divisible by 4 is a leap year.
2. But every year divisible by 100 is NOT a leap year
3. Unless the year is also divisible by 400, then it is still a leap
year.

So, you run into trouble if your base date is, for example, 2/29/2000.



Be careful…



Louis Kleiman

SSTMS, Inc.



_____

From: Christian Gütter [mailto:news@...]
Sent: Tuesday, March 01, 2005 11:38 AM
To: Ian A. Newby
Subject: Re: [firebird-support] Re: Subtract Years from a Date Value in SQL



Hi Ian,

> or update mytable set datefield = cast (extract(day from datefield) ||
> '.' || extract(month from datefield) || '.' || (extract(year from
> datefield)-100) as date)

thanks, this works for me.

> I'm not sure what would happen to leap years though.

I am in the comfortable position that the day and month part of the
date is correct and only the year part is 100 years in the future, so
that I do not need to care for leap years ;-)

Thanks to all of you!


Christian






Yahoo! Groups Sponsor



ADVERTISEMENT

<http://us.ard.yahoo.com/SIG=1292ciqtl/M=298184.6018725.7038619.3001176/D=gr
oups/S=1705115386:HM/EXP=1109781533/A=2593423/R=0/SIG=11el9gslf/*http:/www.n
etflix.com/Default?mqso=60190075> click here



<http://us.adserver.yahoo.com/l?M=298184.6018725.7038619.3001176/D=groups/S=
:HM/A=2593423/rand=237336884>



_____

Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

* To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com
<mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>

* Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/> Terms of Service.



[Non-text portions of this message have been removed]