Archives of the TeradataForum
Message Posted: Tue, 03 Jan 2006 @ 15:30:39 GMT
Subj: | | Re: CEIL & Least function in TD |
|
From: | | Geoffrey Rommel |
| I have a command in Oracle | |
> CEIL(LEAST(TO_DATE('31-DEC-2005','DD-MON-YYYY'),SYSDATE) - DUE_DATE)
Actually, this is an expression, not a command. LEAST returns the smallest of its arguments, so it would be equivalent to this case
expression:
case
when current_date < date '2005-12-31' then current_date
else date '2005-12-31'
end
But now this expression will always return '2005-12-31', so you could just hard-code it (unless we're missing some logic).
CEIL returns the next higher integer; for instance, ceil(7.2) is 8. But in Teradata, subtracting a date from a date always returns an integer,
so there is no need for the ceiling function. Thus the whole expression becomes:
(case
when current_date < date '2005-12-31' then current_date
else date '2005-12-31'
end) - due_date
|