November 6th, 2008

YEAR MONTH Data

Posted by admin in F. Data Types

The year-month interval has to do with the difference between dates and contains a year value, a month value, or both.

The formats are:

INTERVAL YEAR
INTERVAL YEAR(precision)
INTERVAL MONTH
INTERVAL MONTH(precision)
INTERVAL YEAR TO MONTH
INTERVAL YEAR(precision) TO MONTH

Examples:

INTERVAL '12-7'                  12 years and 7 months.
INTERVAL '12-7' YEAR TO MONTH    12 years and 7 months.

Changing a date with an INTERVAL:

NewDate = DueDate + INTERVAL '7' DAY

Finding the number of days between two dates:

DaysLate = (DatePaid - DueDate) DAY
(DATE '2056-03-20' - DATE '2055-01-10') YEAR TO MONTH = '0001-02' (Or 1 year and 2 months.)

Leave a reply

:mrgreen: :neutral: :twisted: :shock: :smile: :???: :cool: :evil: :grin: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad: