COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Framework Manager => Topic started by: philelmousse on 19 Jul 2011 09:50:53 AM

Title: error in if statement
Post by: philelmousse on 19 Jul 2011 09:50:53 AM
Hello,

I created a filter in my query subject but there is an error. Are you able to find it ?

The error is on first line, at "<=3" statement

case
when (extract(year from gl_account.valid_from) = 2011) then (extract(month from gl_account.valid_from) <= 3)
else (extract(year from gl_account.valid_from) <= 2011) end
and
((extract(year from gl_account.valid_to) >= 2011) and (extract(month from gl_account.valid_to) >= 3))


Thanks
Title: Re: error in if statement
Post by: rockytopmark on 19 Jul 2011 11:23:04 AM
Your use of Extract must be in syntax of your specific rdbms rather than Cognos, as here is Extract() function's syntax for Cognos:

extract ( datepart , datetime_exp )
Returns an integer representing the value of datepart (year, month, day, hour, minute, second) in "datetime_exp".

hth
Title: Re: error in if statement
Post by: philelmousse on 19 Jul 2011 12:59:52 PM
I create a timestamp with Month prompt and year prompt like this :

_make_timestamp (  cast(?year?,int),cast(?Month?,int),0)

I use that calculation item to filter a query calculation on a date column and get that error :

UDA-SQL-0564 [Microsoft OLE DB Provider for SQL Server]The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. (SQLSTATE=22007, SQLERRORCODE=242)
Title: Re: error in if statement
Post by: Lynn on 19 Jul 2011 01:02:59 PM
The make timestamp function has three arguments: year, month, day. Your expression looks like it is trying to use day number 0 which would not translate to a valid date.