COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: kc9400 on 19 Aug 2013 07:36:43 AM

Title: [SOLVED]Conversion failed when converting date and/or time from character string
Post by: kc9400 on 19 Aug 2013 07:36:43 AM
I'm trying to display the latest signed months of data, I've selected the MAX months and then I need to display all the months that are

<= the selected month in the prompt.

When running the report I am getting a Conversion failed as shown in the subject, the prompt loads fine but when actually getting to the data this happens.

I've tried a couple of converts and casts but to no joy. Also this is in a nested query, I don't know if I'm just trying to do something that isn't possible or if I'm just lacking knowledge or both  ???

'AND tblsomething.Month <= (#prompt('DatePicked')#)'  was the initial entry

This is one I tried but no joy 'AND CAST (tblsomething.Month AS DATETIME) <= (#prompt('DatePicked')#)' 

Any help, tips or advice would be appreciated.
Title: Re: Conversion failed when converting date and/or time from character string.
Post by: Lynn on 19 Aug 2013 09:27:25 AM
What is the contents of your tblsomething.Month column? Is it a string containing the month name or an integer containing the month number? If it contains something like "January" or "01" then there is no way to convert that to a date.
Title: Re: Conversion failed when converting date and/or time from character string.
Post by: kc9400 on 19 Aug 2013 09:44:22 AM
The Month is a DATETIME column.
Title: Re: Conversion failed when converting date and/or time from character string.
Post by: Lynn on 19 Aug 2013 09:46:47 AM
Then you don't need to cast it.
Title: Re: Conversion failed when converting date and/or time from character string.
Post by: kc9400 on 19 Aug 2013 10:09:55 AM
Yeah that's what I thought, but with or without the cast I'm running into the conversion failed which I can't understand why.

I've now put in a Date Prompt object which is doing what I want it to do but it'd be nice to know why my initial method of doing it wouldn't work.

Apologies if it's too vague.
Title: Re: Conversion failed when converting date and/or time from character string.
Post by: Lynn on 19 Aug 2013 10:13:01 AM
My guess would be that the problem originated with the prompt side of things, so using the right prompt control is a good way to go.
Title: Re: Conversion failed when converting date and/or time from character string.
Post by: kc9400 on 20 Aug 2013 03:05:29 AM
Will have to play around with it, recreate the problem and see if I can make it work another way  :)


Thanks for your help and advice Lynn
Title: Re: Conversion failed when converting date and/or time from character string.
Post by: Lynn on 20 Aug 2013 07:18:09 AM
What type of prompt control were you using originally? If it was a text box prompt then I would hazard a guess that the way the date was entered might affect the success of the cast.

A couple things to consider:

Good luck!