I have a Database which is having a Counterdate time Column stored in the form of Char(24)
But i need it to be in form of datetime so that i can use the datetime functions on it..When i use the cast or convert inside the function where i am passing this character it gives me error
"Conversion failed when converting datetime from character string."
I am done all permutatiions and combinations for this used
Set @.DE = convert ( datetime, @.ts,121)
Set @.de = cast( @.ts as datetime)
BUT ALWZ give me same error.... also when i copy the whole of the data table into some other database the error doesnt come.. i converts the character into the datetime..
I DONT understand why the Server is behaving wiered..
Hoping to get an answer soon.
With regards
Sharad
Database Developer ,
UIC
Hi Sharad,
Can you post a sample of the (character) data that is causing the issue?
Thanks,
Rob
|||Sir,
I am just using the performance Logs of the a server and in that the database get automatically generated and hence..
I get the data of datetime column in Char(24) form.. and when i use an function to convert that into a datetime form it gives me error..
take anytime .e.g of the form
"2006-11-15 17:33:22.015"
if this is the time stamp and stored in the char(24) format and I want it to be datetime ...
What any sensible person would do
1. cast it into datetime
2. Convert into datetime..
Both not working ..
With regards
Sharad
|||PLZ reply if u could Help with this simple STUFF
This CODE I RUN
DECLARE @.DS char(24)
SEt @.ds = '2006-10-27 20:01:13.297'
print @.ds
declare @.de datetime
Set @.de = convert(datetime, @.ds, 121)
print @.de
Output is
:::
2006-10-27 20:01:13.297
Oct 27 2006 8:01PM
But i want output to be exactly same
as 2006-10-27 20:01:13.297
Plz help me with this..
|||
change your statement as below,
DECLARE @.DS char(24)
SEt @.ds = '2006-10-27 20:01:13.297'
print @.ds
declare @.de datetime
Set @.de = convert(datetime, @.ds, 121)
print convert(varchar, @.ds, 121)
No comments:
Post a Comment