.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Using date as a parameter

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :Sql Server
Environment: 2008 SSRS, 2008 visual studio We run our reports in two modes. User selects a report from a menu on a web page, the report displays and waits for them to enter some filter parameters. Or, some pages have a print button where the report is run with all the required parameter values pulled from the the data state of the page with the button. The same RDL is used in both instances. One particular report has dates as required parameters. When the report is run prompting the user for parameters it works great. When run at the press of a button is when we have problems. The pertinent sections of the RDL look like this: In the parameter section the parameter is defined like:     <ReportParameter Name="FromChangeDate">       <DataType>DateTime</DataType>       <Prompt>From Change Date</Prompt>     </ReportParameter> In the query section the parmeter is defined:           <QueryParameter Name="@FromChangeDate">             <Value>=Parameters!FromChangeDate.Value</Value>           </QueryParameter> The corresponding parameter in the stored procedure is defined: @FromChangeDa

View Complete Post

More Related Resource Links

Date Picker Parameter

hi guys... I can't get the date picker for ssrs 08 reports to work. My underlying columns is a datetime type and as far as I know that should do it. It just shows the dates as normal entries even though I changed the Data type from text to date/time in the report parameters properties. Any idea much appricated? Thx

Unble to pass date parameter to "Go to Report " ?


Hi ,

I have Report A need to go from Report A to Report B passing multivalued parameter and date parameter as well , I do not have any problem passing  Multivalued parameter but cant pass date parameter from Report A and Report B .

Report A : Date parameter properties

name : date

Data Type : Date/Time

Default value =Today()

Report B : Date parameter properties

name : date

Data Type : Date/Time

Default value =Today()

Go to Report action ,Expression used to pass date parameter  from Report A to Report B


Unable to pass appropriate date parameter if changed from default value from ReportA to ReportB .

Assistance would highly be appreciated !!

Thanks .

Rajkumar Yelugu

remote execution of ssis package using wcf doesn't like date parameter


I have a ssis package remotely executed by a C# windows application that runs ok in context of SSIS installed on the desktop; I created a wcf windows service that the C# application executes, creates a copy of the package with the date in the variable, but errors on the first SQL task component that requires the date. The copy executes using the SSIS utility. What is possibly the issue with wcf and the date type in the SSIS package? Here is the error:

OnError,SRVR2BLADEA3,MIC\1347259,Clear CII ImportDate,{AB3CF5BA-C114-40F6-9ECB-4C7620D97829},{8B1C10CB-580F-4BFE-BC7D-0B97C181E307},9/27/2010 3:29:56 PM,9/27/2010 3:29:56 PM,-1073548784,0x,Executing the query "" failed with the following error: "The type initializer for '<Module>' threw an exception.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

Here is the code:

case @"E:\SSIS Packages\CIISCImport.dtsx":

//string dtValue = (prms[iPrms - 1].Split('=').GetValue(1).ToString()) + " 12:00";

vars["User::ImportDate"].Value = DateTim

Date as a Search Parameter



I am trying to get gridview populated on the basis of Date as a search parameter.

Date Textbox is taking date as MM-dd-yyyy.

Date format in table is dd/MM/yyyy HH:mm:ss.

The problem is that when I give date for example 30-04-2010, the data is not populating to gridview as the date in the table is 30/04/2010 12:00:00 .

Actually I want to know query.

Any idea would be helpful.

Restricting Date Parameter Values


I have a daily revenue report (with 1 date parameter) that runs daily via report subscription.  Is there a way to restrict the date parameter so it can only select from 2009/1/1 up to Yesterday.  Our daily ETL process will process yesterday's data around 6:00 am, if the user picks a wrong date then the report will be incomplete.  I use =DateAdd("d",-1,Today()) for my default date parameter.

Is there a way to come up an explanation or a message  that “processing has not completed” or “data not available” if the user try to pull a report with wrong date?


Thanks, Michael Mei

SSIS - Passing a date parameter to a SQL Query question again....


I need to pass a date string to my sqlcommand inside of my "datareader source".  I read some of the questions about setting expression variables but I can't seem to figure out how to do it.  I pasted the query below.  The table name contains a date in it so I need to pass that date as a string into my sqlcommand at runtime.  Do I create a variable with the entire SQL command in it or can I just create a single variable that holds the date and just reference that in my datasource reader sqlcommand property?  Can someone assist me with the syntax for creating the expression?

     pages_20101006.`date` AS full_date,
     pages_20101006.`cat` AS category_no,

Thanks very much,



reportviewer date parameter and calendar.. not working and javascript errors??



Hi, I've got this ssrs 2005 report that works great passing a few
security related parameters from asp.net codebehind. However, there
are two date related parameters that won't be coming from my web form,
but rather from the report form itself. When I test the report's date
parameters from visual studio it work fine, but when I attempt the
same report from a reportviewer no matter what input I place on the
report's date fields or even if I select the date picker, the report
simply resets to default and reloads. And actually the date picker
from the reportviewer does not not even pop up.


Here's my aspx code:

<%@ Page Language="VB" AutoEventWireup="false"
Inherits="_ReportViewer" MasterPageFile="~/Main/MasterPage.master"
    CodeFile="~/Reports/CashSales.aspx.vb"  Title="Cash Sales" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms,
Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Content1"

SSRS Date Time value in parameter, pass SP



I had a strange problem last week in few SSRS Reports, scheduled in a report server.

SSRS Report

This report uses StartTime and EndTime parameters defined as 'String' data type and the default value is populated from a dataset. (Format of String, 10/29/2010 6:00:00 AM)

The report uses a stored procedure (stored_proc) to pull the report data from the SQL Server database for display in the report.

The SP stored_proc uses 3 input parameters named below
@par1 nvarchar(4000)
@StartTime nvarchar(20)
@StopTime nvarchar(20)

It was worked well for the past one year, but suddenly it stop run in production and throws the below error.

System.Data.SqlClient.SqlException: Conversion failed when converting datetime from character string.

When we look at the SP, the below line of code throws the error(CreateDate is the database table column).

Where (CreateDate >= @StartTime AND CreateDate < @StopTime ) 

From the profiler log, we understand that the below statement was triggered by SSRS.

exec stored_proc @par1=N'4',@StartTime=N'10/29/2010 6:00:00 AM',@StopTime=N'10/29/2010 6:00:00

ssrs dropdown parameter with Week startDate and end date so that user selects only week and report s


Hi all,

I have a report where I have to show the Week start and end date in the dropdown instead of the date range. Please advice me how to proceed with this report parameter. Thanks a lot in advance, all help is appreciated.


SSRS 2008 - Passing parameter into textbox - can't seem to apply formatting to it (date/currency)


I have a report that is displaying a parameter in a textbox inside the report.

Now I right clicked on the textbox, went to properties, and set number formatting to: Date - 01/31/2000

However, when I render the report it does not display the date in that format. It displays it in the way the sproc returns it which is: 5/13/2011 3:08:30 PM

I tried changing the parameter type to TEXT instead of datetime, made no difference.

I am having the same problem with currency. I will return 12345 and it will just display that way in the textbox instead of $12,345.00.

Any suggestions?

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

How To Set a Date Format In GridView Using ASP.NET 2.0

A very common desire is to set a column of a gridview to display just the month, day and year of a DateTime type. The problem is the by default, the HtmlEncode property of the boundfield attribute (
The problem is that if this field is enabled, you can not pass format information to the boundfield control. That is, if you try the following code, you will not get the desired result.

jQuery Date picker Implementation in ASP.NET

I've posted a wrapper ASP.NET around the jQuery.UI Datepickercontrol. This small client side calendar control is compact, looks nice and is very easy to use and I've added it some time back to my control library.

This is primarily an update for the jQuery.ui version, and so I spend a few hours or so cleaning it up which wasn't as easy as it could have been since the API has changed quite drastically from Marc's original implementation. The biggest changes have to do with the theming integration and the resulting explosion of related resources.

If you want to use this component you can check it out a sample and the code here:

How to format datetime & date with century?

Execute the following Microsoft SQL Server T-SQL datetime, date and time formatting scripts in Management Studio Query Editor to demonstrate the usage of the multitude of temporal data formats available and the application of date / datetime functions.


Date and Time Functions in SQLSERVER

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

1 DATEPART Function
2 DATENAME Function
3 DAY, MONTH, and YEAR Functions
5 DATEADD Functions
6 DATEDIFF Function
7 More SQL Server Functions

Data Types - Date and Time in SqlServer

Date and time values can be stored with either the DATETIME or SMALLDATETIME data type. The difference between the two is that SMALLDATETIME supports a smaller range of dates and does not give the same level of precision when accounting for time. The DATETIME data type can hold values from January 1st of 1753 to December 31st of 9999. The time is stored to the 1 three hundredths of a second and each value takes up 8 bytes of storage. The SMALLDATETIME data type can hold values between January 1st 1900 and June 6th of 2079. The time is tracked to the minute and each value takes up 4 bytes of storage. The majority of business applications can live happily with SMALLDATETIME, however, if you are in an environment where each second matters or you need to make estimates to the distant future (or past) then you have to resort to DATETIME. If you fail to specify the time when inserting a value into a DATETIME or SMALLDATETIME column, a default of midnight is used. If you fail to specify the date portion the default of January 1, 1900 is used.

Built-in Functions - Date and Time Functions

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend