How does "interval 'n' month" work?

Database
Enthusiast

How does "interval 'n' month" work?

Hi All,

The result of running "sel add_months(date '2011-03-31',-1);" will be : "2011-02-28".

But the result fo running "sel date '2011-03-31' - interval '1' month;" will be "2665:  Invalid date".

How does  "interval 'n' month" work? 

1 REPLY
Junior Supporter

Re: How does "interval 'n' month" work?

Intervals are intervals: they are 'irrespective' with dates. In TD (and in other RDBMS's, like Oracle) if you add (or substract) intervals to dates (as in your example) the result will be pure arithmetic, which can yield an error.

More of this here (in spanish, as usual):

http://carlosal.wordpress.com/2011/06/13/intervals-year-month-y-dates-en-teradata/

HTH.

Cheers.

Carlos.