Subject Re: [firebird-support] Subtract Years from a Date Value in SQL
Author Martijn Tonies
> > is there a reliable way to subtract e. g. 100 years from a
> > date value?
> >
> > My problem is that I would like to subtract 100 years from a given set
> > of date values and it would be very convenient to do it with a simple
> > SQL statement.
>
> At least approximately:
>
> select datefield - (100 * 365.25) from table
>
> :)
>
> (Problem are the leap years)

Indeed. And they depend on the original year given.

Perhaps it would be better to write an UDF in which
you decode the date, subtract 100 years and encode
it again. That way, the leap years are included.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server
Upscene Productions
http://www.upscene.com