Solved

how to convert nvarchar to datetime

Posted on 2011-03-07
5
631 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

896 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now