All Forums Database
whitestorm2k 8 posts Joined 09/04
30 Oct 2012
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? 

CarlosAL 512 posts Joined 04/08
30 Oct 2012

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.

You must sign in to leave a comment.