F_ADDYEAR

<< F_DOMAINFROMEMAIL | IBExpert UDF Functions | F_ADDMONTH >>

F_ADDYEAR

 

substitutable with DATEADD

  • compatibility to FreeUDFLib, FreeUDFLibC, FreeUDFLib AvERP, GrUDF
  • Compatible with UTF-8
  • Input TIMESTAMP date optionally time, INTEGER years to add
  • Output TIMESTAMP adds years to timestamp

If parameter 2 is negative, years to subtract. If the outputyear is a non-leapyear, for input 29th February the output is 1st March.

Example

 select cast('01.10.2018 15:03:01' as timestamp) as ISCORRECT, F_ADDYEAR('01.10.2015 15:03:01', 3)
 from RDB$DATABASE
 union
 select cast('01.10.2015 15:03:01' as timestamp) as ISCORRECT, F_ADDYEAR('01.10.2018 15:03:01', -3)
 from RDB$DATABASE
 union
 select cast('29.02.2020 15:03:01' as timestamp) as ISCORRECT, F_ADDYEAR('29.02.2016 15:03:01', 4)
 from RDB$DATABASE
 union
 select cast('01.03.2017 15:03:01' as timestamp) as ISCORRECT, F_ADDYEAR('29.02.2016 15:03:01', 1)
 from RDB$DATABASE
 union
 select cast(null as timestamp) as ISCORRECT, F_ADDYEAR(null, null)
 from RDB$DATABASE;

Expected results:

                 ISCORRECT
 ========================= =========================
                    <null>                    <null>
 2015-10-01 15:03:01.0000  2015-10-01 15:03:01.0000
 2017-03-01 15:03:01.0000  2017-03-01 15:03:01.0000
 2018-10-01 15:03:01.0000  2018-10-01 15:03:01.0000
 2020-02-29 15:03:01.0000  2020-02-29 15:03:01.0000

back to top of page
<< F_DOMAINFROMEMAIL | IBExpert UDF Functions | F_ADDMONTH >>