COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Gnani on 11 Jul 2011 06:36:56 AM

Title: JAVASCRIPT to convert datepormpt values
Post by: Gnani on 11 Jul 2011 06:36:56 AM
Hi,
I need JAVASCRIPT to take the values from date prompt and convert it to 'DD-MON-YYYY' format and pass it to the database for filtering.

Can any help in this regard.

Thanks in adv
Gnani
Title: Re: JAVASCRIPT to convert datepormpt values
Post by: Lynn on 11 Jul 2011 07:42:59 AM
What database requires that? Is it a date datatype or a string datatype in the database?

If it is a string then just convert your date to a string. No need for javascript.

For example, if you have Oracle you could use the TO_CHAR function to convert date to a specific string format. For other databases try the CAST function.
Title: Re: JAVASCRIPT to convert datepormpt values
Post by: Gnani on 12 Jul 2011 06:32:00 AM
Thanks Lynn for the reply,
db is oracle here.
we can't convert since this parameter comes from FM and moreover we took it from Strored procedure.

Thanks
Gnani
Title: Re: JAVASCRIPT to convert datepormpt values
Post by: Gnani on 12 Jul 2011 06:33:11 AM
Datatype for this column in the database is varchar. So we have to conevert.

Thanks,
Gnani
Title: Re: JAVASCRIPT to convert datepormpt values
Post by: Lynn on 12 Jul 2011 07:04:05 AM
Ok, so you have a date prompt control which allows the user to pick a date using the calendar widget. You need to make that a string to pass to the stored procedure. With Oracle I think you'd just need to wrap a TO_CHAR function around your parameter.

I don't have Oracle at my current client but something like this might work for you.

TO_CHAR(?DateParam?,'DD-MON-YYYY')
Title: Re: JAVASCRIPT to convert datepormpt values
Post by: Gnani on 18 Jul 2011 08:07:00 AM
Hi Lynn,
I tried the one which u told but giving below error message:

RQP-DEF-0177 An error occurred while performing operation 'sqlExecute' status='-9'.
UDA-SQL-0107 A general exception has occurred during the operation "execute".
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at "tablename.colname", line no
ORA-06512: at line 1



Can any one help me out in this regard,

Thanks in adv,
Gnani
Title: Re: JAVASCRIPT to convert datepormpt values
Post by: Lynn on 18 Jul 2011 08:19:28 AM
What is the column that it is complaining about? You said your column is a varchar so it shouldn't be upset that it got non-numerics instead of numerics.

The error indicates that you're trying to provide something other than numbers for a field that is a numeric datatype.

Might be a good idea to figure out how to call the procedure directly (not using Cognos), then you'll better understand how to execute it via Cognos.