INTERVAL Data
An interval is the difference between two datetime values.
In many applications that use dates and times, you sometimes need to determine the interval between two dates or times.
An interval contains the amount of time between two date/time values.
An interval can be used to increase or decrease the value of a date or time.
While various RDBMS systems have their own unique functions to handle these intervals, SQL defines two distinct types of intervals: the year-month interval and the day-time interval.A year-month interval contains the number of whole years and months between two dates.
A day-time interval contains the number of days, hours, minutes, and seconds between two times.
A multiple field qualifier is stated:Â Â Â Â Â Â Â Â Â Â INTERVAL start_field TO end_field
where start_field can be YEAR, DAY, HOUR, or MINUTE,
and the end_field can be YEAR, MONTH, DAY, HOUR, MINUTE, or SECOND.
Start_field must be smaller than end_field.
Start_field can have a precision, but end_field can only have a fracional-precision on SECOND.
> You can not add two dates because it makes no sense and SQL will not allow it.
> You can do calculations with intervals.
> Intervals can be added or subtracted.
> Interval field separators are the same as date/time field separators.
> When doing calculations, you can not mix year-month interval calculations with day-time interval calculations because months come in varying lengths of 28, 29, 30, and 31 days.
> INTERVAL is not supported by Access, DB2, MySQL, or SQL Server.
Very usefull, Thanks