Showing posts with label input. Show all posts
Showing posts with label input. Show all posts

Friday, March 9, 2012

Pull between 2 dates from user input

I want to pull dates from my database that are between to set dates i have written a query that does this which looks like this:

"SELECT OCH_ID, empno, Selected_OCD, Start_Time, End_Time, Selected_OCDay, Selected_DOM, Selected_Month, Selected_Year FROM dbo.ICT_On_Call_Hours WHERE (CONVERT (datetime, LEFT (Selected_OCD, 2) + '/' + SUBSTRING(Selected_OCD, 4, 2) + '/' + RIGHT (Selected_OCD, 4)) >= CONVERT (datetime, LEFT ('12/02/2007', 2) + '/' + SUBSTRING('12/02/2007', 4, 2) + '/' + RIGHT ('12/02/2007', 4))) AND (CONVERT (datetime, LEFT (Selected_OCD, 2) + '/' + SUBSTRING(Selected_OCD, 4, 2) + '/' + RIGHT (Selected_OCD, 4)) < CONVERT (datetime, LEFT ('14/02/2007', 2) + '/' + SUBSTRING('14/02/2007', 4, 2) + '/' + RIGHT ('14/02/2007', 4)))"

This works when the dates are included in the statement but when i try and use parameters to pull them in like this:

"SELECT OCH_ID, empno, Selected_OCD, Start_Time, End_Time, Selected_OCDay, Selected_DOM, Selected_Month, Selected_Year FROM dbo.ICT_On_Call_Hours WHERE (CONVERT (datetime, LEFT (Selected_OCD, 2) + '/' + SUBSTRING(Selected_OCD, 4, 2) + '/' + RIGHT (Selected_OCD, 4)) >= CONVERT (datetime, LEFT ('@.Choice1', 2) + '/' + SUBSTRING('@.Choice1', 4, 2) + '/' + RIGHT ('@.Choice1', 4))) AND (CONVERT (datetime, LEFT (Selected_OCD, 2) + '/' + SUBSTRING(Selected_OCD, 4, 2) + '/' + RIGHT (Selected_OCD, 4)) < CONVERT (datetime, LEFT ('@.Choice2', 2) + '/' + SUBSTRING('@.Choice2', 4, 2) + '/' + RIGHT ('@.Choice2', 4)))"

I then recieve the following error message why is this?

ERROR ------> Syntax error converting datetime from character string.

Any Help would be greatly appreciated thanks

Dont surround a parameter with single quotes. Also if choice1 is a data already why not try something like this

"SELECT OCH_ID, empno, Selected_OCD, Start_Time, End_Time, Selected_OCDay, Selected_DOM, Selected_Month, Selected_Year FROM dbo.ICT_On_Call_Hours WHERE (CONVERT (datetime, LEFT (Selected_OCD, 2) + '/' + SUBSTRING(Selected_OCD, 4, 2) + '/' + RIGHT (Selected_OCD, 4)) >=@.Choice1 AND (CONVERT (datetime, LEFT (Selected_OCD, 2) + '/' + SUBSTRING(Selected_OCD, 4, 2) + '/' + RIGHT (Selected_OCD, 4)) <@.Choice2"

|||

Thanks for the immediate response that works perfectly exactly what i wanted

Thanks Again

Dazza22

Wednesday, March 7, 2012

Published Reports -- URGENT

Hi
I am trying to supply input parameters to a report from an aspx page. I tried many methods , but none seem to be working.
Can anyone suggest how I can work with parameterized reports from code?
Moreover , Do I have to publish a report to be able to supply Report Parameters from the code?
Thanks
--
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.You always have to publish a report to the server before you can use it. Not
sure what you are trying to do.
Are you using URL Access or the SOAP API? Supplying paramters to each is
described in BOL.
--
Brian Welcker
Group Program Manager
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"SqlJunkies User" <User@.-NOSPAM-SqlJunkies.com> wrote in message
news:uOaURsuZEHA.3112@.TK2MSFTNGP09.phx.gbl...
> Hi
> I am trying to supply input parameters to a report from an aspx page. I
> tried many methods , but none seem to be working.
> Can anyone suggest how I can work with parameterized reports from code?
> Moreover , Do I have to publish a report to be able to supply Report
> Parameters from the code?
> Thanks
> --
> Posted using Wimdows.net NntpNews Component -
> Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine
> supports Post Alerts, Ratings, and Searching.|||Hi
This is what i think.
1) in your .aspx page, you would have a hyperlink or something that links to the targeted report Eg:
<a href="http://links.10026.com/?link=http://localhost/Reportserver?/report1¶m1=123" >Go to report1</a>
2) In report1.rdl, you would have created a parameter called param1.
3) You definitely need to publish your report. You do this through the report manager: upload.
Chiara
"SqlJunkies User" wrote:
> Hi
> I am trying to supply input parameters to a report from an aspx page. I tried many methods , but none seem to be working.
> Can anyone suggest how I can work with parameterized reports from code?
> Moreover , Do I have to publish a report to be able to supply Report Parameters from the code?
> Thanks
> --
> Posted using Wimdows.net NntpNews Component -
> Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
>