Subject Re: Add Year function
Author Adam
> The reason I need to add 100 years is I exported data from MS
Access 2
> to Firebird.
> I found some of the date were not Y2K compliant, eg. 04/06/2001
became
> 04/06/1901.
>
> So I need to convert them by adding 100 years into the data.
> If the date is less than 1910 after export I found these need to be
> added by 100 years, that's why I need the update statement.

OK, well you can just add the appropriate number of days.

For dates >= 1 Mar 1900, simply add 36525
For dates <= 28 Feb 1900, simply add 36524

For the date 29 Feb 1900, there is no corresponding day (you are
stuffed in this case). 1900 is a leap year but 2000 was not.

Adam















>
> --- In firebird-support@yahoogroups.com, "Adam" <s3057043@> wrote:
> >
> > --- In firebird-support@yahoogroups.com, "alanpltse" <alanpltse@>
> > wrote:
> > >
> > > Hi Adam,
> > >
> > > I created the UDF by the scripts with no error:
> > > DECLARE EXTERNAL FUNCTION ADDYEAR
> > > DATE,
> > > INTEGER
> > > RETURNS DATE BY VALUE
> > > ENTRY_POINT 'IB_UDF_AddYear' MODULE_NAME 'ib_udf'
> > >
> > > So I assume Firebird knows where 'IB_UDF_AddYear' and 'ib_udf'
are.
> > >
> > > But it only happens when I create the stored procedure, it
seems not
> > > related to the date format.
> > >
> > > As the error message pointed to the entry_point and module_name.
> > >
> > > Besides using UDF, any way inside the stored procedure can add
100
> > > years to the date ?
> > >
> > > Alan
> >
> > Perhaps using extract keyword you could reduce it to the elements
then
> > combine it somehow. Out of curiousity, how do you intend on
handling
> > leap years and days from previous centuries where people did not
agree
> > on the date because they didn't want to switch calendars?
> >
> > +1 adds a day, so providing you know how many days you want to
add, it
> > is pretty simple.
> >
> > Adam
> >
>