November 11th, 2008

DATE/TIME/INTERVAL Data Arithmetic

Posted by admin in F. Data Types

Many RDBMS systems have their own functions for date/time math.
You can generally perform the following operations:> Subtract two date/times to get an interval.
> Add or subtract an interval and a date/time to get a future or past date/time.
> Add or subtract two Intervals to get a new Interval.
> Multiply or divide an Interval by a number to get a new Interval.

Adding two dates makes no sense.

EXTRACT() can be used to retrieve a single field from a date, time, or timestamp.

> Access and SQL Server have a DATEDIFF() function.
> MySQL has DATE_ADD() and DATE_SUB() functions.
> Oracle has an ADD_MONTHS() function.

Comments are closed.

Sorry, the comment form is closed at this time.