Re: I was told there would be no (date) math

  • From: "Richard Ji" <richard.c.ji@xxxxxxxxx>
  • To: Rich.Jesse@xxxxxx
  • Date: Thu, 13 Apr 2006 13:19:01 -0400

Without the parenthesis, the whole thing is evaluated from left to
right.  So the first trunc(sysdate) - trunc(sysdate) results in 0,
then it becomes 0 - trunc(sysdate) so you get inconsistent data type. 
The error message is a bit confusing though.

In the second try with the parenthesis, the expression within the
parenthesis is evaluated first which is 0.  Then it becomes
trunc(sysdate) - 0 and that's a simple date arithmetic.

Richard Ji

On 4/13/06, Jesse, Rich <Rich.Jesse@xxxxxx> wrote:
> Hey all,
>
> While debugging an analytical function issue using 9.2.0.5, I run this
> idiotic query:
>
> SELECT TRUNC(SYSDATE) - TRUNC(SYSDATE) - TRUNC(SYSDATE)
> FROM DUAL;
>
> And it errors out with:
>
> ORA-00932: inconsistent datatypes: expected DATE got DATE
>
> (In 10.2, the verbage is modified to "expected JULIAN DATE got DATE")
>
> Add parenthesis and it works:
>
> SELECT TRUNC(SYSDATE) - (TRUNC(SYSDATE) - TRUNC(SYSDATE))
> FROM DUAL;
--
//www.freelists.org/webpage/oracle-l


Other related posts: