I have a table with a column name Tdate, data type datetime, and length 8.
The look of the existing data in this column is from this format
DD/MM/YYYY HH: MI: SS.
I want to pass to a stored procedure string and another data that will
update a specific row, where the string I pass is equal to the value in the
column.
That’s why I want to convert the value of the column from datetime to
nvarchar.
My problem is I do not find the date format I wrote above – I searched in
sql books online and over the Internet.
I tried the following code (because it looks the most similar to the format)
and more others.
CONVERT(CHAR(30), Tdae, 131)='11/05/2006 12:20:35'
Can you please tell me how can I convert the datetime to nvarchar that will
look like that format?
Or – convert the string that looks like the format above to datetime from
that format.
Thanks in advance!Hi,
Converting datetime to varchar for comparison is not a good option.
But you can convert varchar to datetime.
Can't you use somthing like this for comparison?
Tdae = cast('11/05/2006 12: 20: 35' as datetime)
Or have I understood the question wrong?
--
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/|||Convert it the other way around instead. See http://www.karaszi.com/SQLServer/in...
_datetime.asp for
elaboration.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Niron kag" <Nironkag@.discussions.microsoft.com> wrote in message
news:A082F020-4217-4571-9E52-C6A8F91E65F8@.microsoft.com...
>I have a table with a column name Tdate, data type datetime, and length 8.
> The look of the existing data in this column is from this format
> DD/MM/YYYY HH: MI: SS.
> I want to pass to a stored procedure string and another data that will
> update a specific row, where the string I pass is equal to the value in th
e
> column.
> That’s why I want to convert the value of the column from datetime to
> nvarchar.
> My problem is I do not find the date format I wrote above – I searched i
n
> sql books online and over the Internet.
> I tried the following code (because it looks the most similar to the forma
t)
> and more others.
> CONVERT(CHAR(30), Tdae, 131)='11/05/2006 12:20:35'
> Can you please tell me how can I convert the datetime to nvarchar that wil
l
> look like that format?
> Or – convert the string that looks like the format above to datetime fro
m
> that format.
> Thanks in advance!
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment