Solved

how to convert nvarchar to datetime

Posted on 2011-03-07
5
630 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
Comment Utility
select convert(datetime, '01:30', 108)
0
 
LVL 23

Expert Comment

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

Expert Comment

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

Accepted Solution

by:
kaminda earned 500 total points
Comment Utility
I would do it like this

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

Expert Comment

by:lalitgada
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
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.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

743 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

17 Experts available now in Live!

Get 1:1 Help Now