Conversion failed when converting datetime from character string on reporting service - reporting-services

when i convert or cast string to date ran succesfull my query from t-sql on sql server but when i assign dataset query on reporting service,i take this error.
'Conversion failed when converting datetime from character string.'

It will depend on the regional settings on your server. I guess your reporting services server thinks days and months are in the opposite position from your SQL server.
The easiest way to consistently get dates to convert from string properly without having to consider regional settings is to use military date format: YYYY-MM-DD
Military format always converts correctly.

Make sure you are not forgetting to put the braces on the "parameter value" field when editing parameters on the DataSet Properties window:
This gives the conversion error:
Parameter Name Parameter Value
#queryDateParameter #reportDateParameter
Correct is:
Parameter Name Parameter Value
#queryDateParameter [#reportDateParameter]

I've had the same issue when trying to pass parameters through SSRS.
when the parameter types are text, SSRS does a conversion using server region settings, in which case, a MM/DD/YYYY and DD/MM/YYYY difference resulted in this error.
Solution for me was to change the parameter type to datetime. This enforces the conversion to be handled correctly.

Related

Automatic conversion MySQL datetime to milliseconds on Apollo client?

I am using Apollo server and Apollo React client. The server runs a query against the MySQL database. In GraphQL schema I have defined the corresponding field sampleTime as String in the type Session. (There is no Date type in GraphQL.) But apparently some kind of default conversion is made on the way between the Apollo server and the result of useQuery. The field sampleTime shows the value as a number and not as a string. The number is apparently the JavaScript Date object.
In this case I don't need such a conversion. I found a solution on the server side by converting the SELECT output to the formatted string.
But why this conversion does occur at all?
Thanks

SSRS issue matching date with parameters

I have a SSRS report using an ODBC connection with MySQL. I have a problem to match the date with the parameters. When I type a date manually in the query it works fine, no problem. But when I use the parameters, it doesn't return anything. One thing I found is that the date data returned is under the format YYYY-MM-DD and the date from parameter is DD/MM/YYYY. I tried CONVERT and STRING_TO_DATE functions of MySQL but no luck. Any clue?
convert the parameter value to a date based on the format sent from the SSRS to match the format you are using in the manual test.
Converting a date in MySQL from string field

SQL statement error in VB.Net

This is the SQL statement which I taken from debug mode in VB.Net.
SELECT dt_Date as 'Date',
s_Time as 'Time',
s_For as 'For',
s_Categ as 'Category',
s_Count as 'Count',
s_Remarks as 'Remarks'
FROM Entry
WHERE (s_ENo = '22' and dt_date BETWEEN '06-05-16' And '27-05-16')
I am not sure what's wrong with the above statement since everything seems to be fine to my eyes.
Description of the Error Message
Additional information: Conversion failed when converting date and/or
time from character string.
Any suggestions how to solve this riddle?
Instead if string literals, use strongly-typed parameters. In addition to avoiding data type conversion issues on the SQL Server side, parameters:
Avoid the need to format date/time string literals in a particular way
Improve performance by providing execution plan resue
Prevent SQL injection (barring dynamic SQL on the server side)
If you are using MS-SQL server than use following instructions.
The basic solution is that you have to provide date into either mm/DD/YYYY format or in YYYY-MM-DD date format into ms-sql query.
So, before passing date to query convert your date into either mm/DD/YYYY format or in YYYY-MM-DD format.
You have to format your date string to YYYYMMDD or if you know the server date format then format same as server

SSRS FormatNumber Error

trying to format number (decimal), but it shows me #Error on production server:
=FormatNumber(First(Fields!SumWithMailDelivery.Value, "document"), 0)
but on developers server it works fine.
Maybe someone know, how can i resolve this?
p.s. without formatting it works on production server fine too.
As #IanPreston says, it is most likely a type conversion error. I imagine your production data has some invalid characters for that column or some Null columns that make the numeric conversion fail.
You can use the Val function to do the conversion. Val differs from other numeric conversion functions in that it won't error when the string to be converted isn't numeric - it just does the best job it can.
So try an expression like this for the Value property:
=IIF(Fields!SumWithMailDelivery.Value Is Nothing,
Nothing,
IIF(IsNumeric(Fields!SumWithMailDelivery.Value),
Val(Fields!SumWithMailDelivery.Value),
Fields!SumWithMailDelivery.Value)
)
then use N0 as the Format property to format it as numeric if possible.
This formula will:
Leave the cell as Nothing if the field is Null
Convert to numeric and use the appropriate format if possible
Otherwise just output whatever is in the field

SQL Server 2008 VarChar To DateTime

I have a table where unfortunately a number of dates are stored as strings.
I have a number of reports that cast them to datetimes and filter by them. This was working fine until today when all of a sudden i'm getting this error
"The conversion of a varchar data type to a datetime data type resulted in an out-of-range value."
The dates are all stored in the format of "yyyy-mm-dd" and are all valid.
If I run the following SQL statement
SELECT CAST('2010-06-02' AS DateTime)
I would expect to get "2010-06-02" however as of today I'm getting "2010-02-06" something has changed with the way SQL formats dates. I've had a look in regional settings on the server and it all looks to be correct.
What else could be causing this?
Try setting the format explicitly
select convert(datetime, '2010-06-02',101)
An unambiguous way of getting this conversion is to do the following:
SELECT CAST(replace('2010-06-02', '-', '') AS DateTime)
And that will always be interpreted as YYYYMMDD, ignoring the set dateformat ydm declaration or any cultural settings that the database has.
Q1: What else could be causing this?
The local, You probably are under the local101(US) and put data from 103 (British/French)
Like barry sad use convert