Problems with DateTime Parameter in SQL2005

  • In this part of the world (Australia) we use dd/mm/yyyy as default date format.

    My report query is:

    Select sometext, dateadded from testdata where dateadded between @start and @end

    I then change the parameter data type for @start and @end to DateTime

    If I use 1st December 2008 (1/12/2008) as @start and 4th Jan 2009 (4/1/2009) as @end when I click the "View Report" button my dates are swapped to mm/dd/yyyy format in the parameter text boxes.

    1/12/2008 becomes 12/1/2008 and 4/1/2009 becomes 1/4/2009.

    The values passed to the report and returned by the query are @start = 12th Jan 2008 and @end = 1st April 2009.

    When entering the dates I get the same results if I type the dates in the parameter text boxes or use the calendar icon to select the date.

    If I change paramater data type to string, everything works fine providing dates are entered correctly. My reason for using DateTime is so end users can click on the calendar icon to select dates.

    I have checked the regional settings on the servers that Reporting Services and my test database are running on and my PC. All are set for dd/mm/yyyy

  • You may want to check out this BOL section: http://msdn.microsoft.com/en-us/library/ms156493(SQL.90).aspx

    Here is one quote:

    Report language

    Reports use language settings for labels and formats:

    * Labels are articulated in the language version of Visual Studio that you are using.

    * Formats for date, currency, and numbers are determined by the server language at run time.

    To override the formatting provided through the server language, you can set the Language property within the report when you design it. If you want to vary the formatting based on the language or local settings of the browser or client application, you can set the Language property to an expression that includes the User!Language variable.

  • Jack,

    I checked the BOL entry you provided (http://msdn.microsoft.com/en-us/library/ms156493(SQL.90).aspx)

    I have been through every setting I can find on both Reporting Services server and the server my database is on. Every regional and language setting I can find is set for Australia.

    I have admitted defeat on this one and have changed my parameters to string data type.

    Ian Scott

  • Is the issue with the display confusing users or with the value being passed by the parameters to the dataset query? I suppose it could be both, but could you live with the display inconsistency if the dates were passed correctly to the query?

  • I am in NZ, and discovered the same problem when we applied SP2 to our report server. The way to resolve is to manually edit ReportViewer.aspx to force the region information to be the correct one (in my case en-NZ). Here's the link that I found when trying to resolve the problem.

    http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/8bc5833b-ffe1-4eeb-8c94-16df4645d326/

    Hope that helps!

    Cheers

    Michelle

  • ian.f.scott (3/2/2009)


    Jack,

    I checked the BOL entry you provided (http://msdn.microsoft.com/en-us/library/ms156493(SQL.90).aspx)

    I have been through every setting I can find on both Reporting Services server and the server my database is on. Every regional and language setting I can find is set for Australia.

    I have admitted defeat on this one and have changed my parameters to string data type.

    Ian Scott

    Have you checked the language of the client's browser?

    It appears to affect the date formatting for parameters - at least for IE 7.

    And the Report Language (in the RDL) affects the formatting of dates within the report.

  • Thank you Michelle from NZ. I added culture="en-au" to ReportViewer.aspx and my report now presents dates correctly in dd/mm/yyyy format.

    No sheep jokes, I promise!

    Ian Scott

  • Ian, glad to have been of assistance. Feel free to make sheep jokes, I'm a transplanted Canadian and won't take offence 🙂

    Cheers

    Michelle

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply