Solved

how to convert nvarchar to datetime

Posted on 2011-03-07
5
634 Views
Last Modified: 2012-05-11
nvarchar contains data like 01:30 now i want to convert into datetime for compare two time plz reply ASAP

Thanks
0
Comment
Question by:gopalhazel
5 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 35065417
select convert(datetime, '01:30', 108)
0
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 35065525
select convert(datetime, <fieldname>,8)
0
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 35065532
OR select convert(varchar(5),<fieldname>,8)
0
 
LVL 9

Accepted Solution

by:
kaminda earned 500 total points
ID: 35066056
I would do it like this

SELECT CAST('01:08' AS DATETIME)
0
 
LVL 1

Expert Comment

by:lalitgada
ID: 35067533
it is too hard first of all it will check based on system date time format structure then culture.

you have to think on the culture format and date time format and the format structure you have set as time zone,

because the sql take system time format as default.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question