|
|
Archives of the TeradataForum
Message Posted: Tue, 31 Oct 2006 @ 13:11:22 GMT
Subj: | | Re: Calculating Months between two dates |
|
From: | | Anomy Anom |
<-- Anonymously Posted: Tuesday, October 31, 2006 07:39 -->
Hi,
I never did that, but approximately could arrive something by the SQL Reference document, chapter 6, Functions and Operators,
PLEASE TEST FOR SYNTAX,
1. SEL (EXTRACT YEAR FROM date2 - EXTRACT YEAR FROM date1 - 1) * 12 +
(EXTRACT MONTH FROM date2 + (12 - ( EXTRACT MONTH FROM date1))
- This doesn't consider the days and could be approximate
2. SEL ((INTERVAL (date1 - date2) YEAR ) * 12 ) +
INTERVAL (date1 - date2) MONTH )
FROM tablename
3. SEL CAST ( INTERVAL (date1 - date2) AS MONTH)
Thanks
| |