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


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

string to datetime conversion using date parameters in SSRS

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :Sql Server
 

Hello, I have a database field that I am pulling that is type string, but the format of each value is mm/dd/yyyy.  I want to convert this to a datetime format (minus the time) so that i can compare this value to a parameter date range (begin date and end date) that are type datetime so that i can use the calendar control in my report.  i've tried in my select statement to use select.....convert(datetime, stringfieldname, 101), but I get an error that says "Conversion failed when converting datetime to character string". 

I am also open to converting the datetime parameters to strings to do the comparison, but not sure the best way to do this either.

thanks!




View Complete Post


More Related Resource Links

want to display 24 hours time and date with datatype Datetime (Not String) in SSRS

  

Hi All,

I want to display 24 hours time and date in SSRS & for that I am using Format(now,"MM/dd/yyyy HH:mm:ss") but I am using this expression in Parameter, where I need to define datatype of that parameter as DateTime, not string. For Expression Format(now,"MM/dd/yyyy HH:mm:ss"), If I use DateTime datatype, It is showing error but working with String datatype.

For example:

I have parameter To Date  and value of this parameter should be 10/11/2010 13:09:16 (To Date: 10/11/2010 23:09:16) , not in AP or PM format and datatype of this parameter, want to keep DateTime that I can select value from Calender.

Please suggest me how I can achieve this?. I don't want to do it in stored Procedure side, want to do it in report side.


Thanks Shiven:)

Conversion from string to type 'Date' is not valid

  

Hi

Im receiving a strange error Error Message: Conversion from string "15/08/2010 22:21:35" to type 'Date' is not valid.

I know this is generally down to cultural date formats etc, however the reason this is strange is it just randomly occured twice in the last week, the website has been running since october and nothing has changed,

The error constantly occured until the IIS was reset and recompilled the site, its been running fine since, however im just trying to figure out what could cause such an error to occur.

I've narrowed it down to a line of code which is:

bktime = DReader.Item("Bktime").ToString

bktime = Year(CDate(bktime)) & "-" & fmt(Month(CDate(bktime)), 2) & "-" & fmt(Day(CDate(bktime)), 2)


Has anyone else encountered this randomly occuring and is there anything i can put in place to prevent this in future?


Cheers


Mike


Data Conversion - string to datetime help!!!

  
Hi all, I need help on concatenate two fields into one then display it as datetime format as such yyyy-mm-dd hh:mm:ss AM/PM. The db is on SQL 2008 SP1. The date and time columns are on the same table and store as varchar. Date has varchar(10) and time has varchar(16). Date column shows result from query is 20100827 while the time column is either 070101.000000 or 070101. The question is how go about concatenate the two together and display in the format above in a report? How should I write my select query for this report? I am using SQL 2008 R2 BI Development Studio to design my report. Thank you. VCHS

Conversion failed when converting date and/or time from character string. SQL 2008

  
The below simple query giving me the "Conversion failed when converting date and/or time from character string." error. Because I've  datatype of "Created" & "Finished" column in below table VARCHAR(100) select * from dbo.mytable where CONVERT(datetime,Created) >= convert(datetime,'9/1/2010') and CONVERT(datetime,Finished) <= convert(datetime,'9/9/2010') In my table i've date stored in below varchar(100) formats. examples: '2010-09-01 11:14:54.000' --Created '2010-09-03 13:43:37.000' --Finished I tried to convert the date in following way but NO luck??? Could you please advise me??? convert(datetime,convert(varchar,convert(datetime,Created),101)) >= convert(datetime,'2010-09-01') and convert(datetime,convert(varchar,convert(datetime,Finished),101)) <= convert(datetime,'2010-09-09') Much appreciated your help!! thanks, pbrathod pbrathod

Conversion failed when converting date and/or time from character string. SQL 2008

  
The below simple query giving me the "Conversion failed when converting date and/or time from character string." error. Because I've  datatype of "Created" & "Finished" column in below table VARCHAR(100) select * from dbo.mytable where CONVERT(datetime,Created) >= convert(datetime,'9/1/2010') and CONVERT(datetime,Finished) <= convert(datetime,'9/9/2010') In my table i've date stored in below varchar(100) formats. examples: '2010-09-01 11:14:54.000' --Created '2010-09-03 13:43:37.000' --Finished I tried to convert the date in following way but NO luck??? Could you please advise me??? convert(datetime,convert(varchar,convert(datetime,Created),101)) >= convert(datetime,'2010-09-01') and convert(datetime,convert(varchar,convert(datetime,Finished),101)) <= convert(datetime,'2010-09-09') Much appreciated your help!! thanks, pbrathod pbrathod

SQL error: Conversion failed when converting date and/or time from character string.

  
I hope someone can advise on the issue I'm having.

This SQL worked beautiful until I added in @startdt and @enddt and this section >> AND [Selldate] BETWEEN ' + @startdt + ' AND ' + @enddt + '

By adding in this condition, I now get the following error:

Msg 241, Level 16, State 1, Line 8
Conversion failed when converting date and/or time from character string.

I have tried changed variables to type = date and various iterations of date formatting, casting with no success. The date in the table is clean as a whistle.

(The CONVERT function is being used in setup for a PIVOT SQL which needs  VARCHAR for column headers)

Thanks in advance for your help, 
JR

declare @itemID varchar(20)
declare @startdt varchar(12)
declare @enddt varchar(12)
set @itemID = ''
set

Conversion from string "09/28/10 9.00AM" to type 'Date' is not valid.

  

I am getting the below error. Please see my code below and let me know what is wrong.

 

dim sDatetime as string = startdate & " " &starttime & "AM"

dim dt as Date = CDate(sDatetime)

I am getting the Conversion from string "09/28/10 9.00AM" to type 'Date' is not valid error in this line. 


Conversion failed when converting datetime from character string. SQL Server @StartDate as datetime

  

Hi,

Can you please help me on this?

When I try to pass my parameter it doesn't work. See below is my code :

 

declare @SQL Varchar(4000)

declare @CRM_FilteredAppointment nvarchar(2000)

declare @CRM_FilteredSystemUser nvarchar(2000)

declare @StartDate datetime

declare @EndDate datetime





set @CRM_FilteredSystemUser = 'Select * from FilteredSystemUser'

set @StartDate = '20080101'

set @EndDate = '20100101'



set @CRM_FilteredAppointment = 'SELECT activityid, participationtypemask 

FROM FilteredAppointment 

WHERE FilteredAppointment.eu_calltype = 2

AND FilteredAppointment.statecode = 1

AND FilteredAppointment.scheduledend >= DateAdd( month, -1, GetD

SSRS - Date Format & Parameters Refresh.

  

Hi,

I am using SSRS 2005 with Enesys Add on Tool for reports.

I have used date format as "dd-MMM-yyyy" in the application and used the same in the report.

Issue : 1

I want to convert this format into a format where i can sort the date fields as and when exported to excel sheets.

Issue : 2

Some of the values are null and when exported to excel cant see the null values. I am using Format function in the conversion so that if the value is nothing, show nothing or show the value.

Need to resolve this as when the report is exported to excel i can see null values or squares in the columns when applying filters.

Issue : 3

The input paremeters are refreshed everytime i select a new value in other parameters. There is no dependency on the input parameters.

Please help me out in resolving these issues ASAP.

Need to submit these today EOD.

Thanks in Advance. 

 


Separate Date and Time report parameters in SSRS 2005

  

Hello,

Is it possible to declare separate report parameters in SSRS 2005 as Date and Time?

I want the user to be able to enter a date and a time.

When I declare the parameters in my stored procedure as datetime, in SSRS the parameter just shows as a Date only.

thanks.


DateTime/String Conversion

  

I have a few date fields on my report and i cannot get them to convert in the correct format.

The default is 08/28/2010 2:30:00 PM and I have used CONVERT(Varchar, EndDate, 103) to convert it to 28/08/2010. But the new date comes out as text format (string) when I copy results into Excel and I want it to stay as a Date type.

Can anyone help please?

Thanks,

ST


SSRS 2008 datetime parameters

  

Greetings:

I am trying to design a report that has a parameter named Time Period which, essentially, has the following available values: Last 24 hours, Last 7 days, Last Month, etc.  I have two other datetime parameters named Start Date and End Date which are going to specify the date ranges for which the report will select the data.

The Time period parameter is needed so that if the user specifies "Last Month", for example, the Start Date and End Date parameters automatically refresh to show the date ranges for the last month.  More so, the user can still be able to specify a different date range that they can pick from the calendar picker.

I have encountered several issues in trying to make this work:

  1. If I only specify a default value to the start date and end date parameters, it will only refresh for the initial run, but will not refresh every time I change the Time Period parameter selection.
  2. If I specify "Available Values" to the datetime parameters, then the parameter will turn into a dropdown field and the user will not be able to choose any date from the calendar picker.

I found a work around for this issue by creating an intermediate parameter and every time I change the time period option it will refresh the parameter since it has a stored procedure assigned

SSRS Date Format in Parameters

  

Hi,

Can we change the date format in the default parameters pane.(For eg : When we create a new parameter and select datatype as date time in report parameters.)

Default settings for this date picker control is mm/dd/yyyy.

I need to change the date to dd/mm/yyyy.

Is it possible to the change this date format to dd/mm/yyyy or any other custom format?

Thanks in Advance.


Date to String Conversion in SSIS Variable

  

Hi All -

I have an SSIS variable whose value is a date formatted as a string in YYYYMM. For example 201011 (meaning Nov 2010). I need to change the value to 201012 (meaning Dec 2010). My thought was to convert 201011 to a date, use dateadd, then convert back to a string. Something like:

(DT_STR)DATEADD(mm, 1, (DT_DBDATE) @[User::strVar] + '01'), 6, 1552)
Can someone point out what I am doing wrong?

How to Encrypt Query String Parameters in ASP.NET

  
Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

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.

http://www.sqlusa.com/bestpractices2005/centurydateformat/

Essential SQL Server Date, Time and DateTime Functions

  
The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all.
Categories: 
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