Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
wira_chen
Starting Member
4 Posts |
Posted - 2005-12-27 : 20:37:18
|
| Hai Bro,I need your help to convert a type nvarchar to datetime or smalldatetime. Datetime (nvarchar) or date(nvarchar) time(nvarchar) 2005 8 25 12 5 18 2005 8 25 12 5 18Results :Datetime (datetime type) date(smalldatetime) timesmalldatetime)2005:8:25 12:05:18 PM 2005:08:25 12:05:18 PMThank's for your interests Bro.RegardsWira Chan |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-12-27 : 21:19:03
|
| Hi Wira Chan,I'm not clear on your requirements. Is this a single value in a table or 2 values or what? >>2005 8 25 12 5 18 2005 8 25 12 5 18Read this link: How to post a question for a database http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxBe One with the OptimizerTG |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-12-28 : 02:18:30
|
| This is the Forum to contribute workable scripts. Hereafter post your questions at relevent forum like DeveloperMadhivananFailing to plan is Planning to fail |
 |
|
|
Frank Kalis
Constraint Violating Yak Guru
413 Posts |
Posted - 2005-12-28 : 02:57:33
|
| [code]DECLARE @wtf NVARCHAR(20)SET @wtf = '2005 8 25 12 5 18'SELECT CAST(REPLACE(RTRIM(LEFT(@wtf,10)), ' ','.') + ' ' + REPLACE(LTRIM(RIGHT(@wtf,8)), ' ', ':') AS DATETIME) ------------------------------------------------------ 2005-08-25 12:05:18.000(1 row(s) affected)[/code]This is not even fun. You should change this via some scripting language before importing it into SQL Server.--Frank KalisMicrosoft SQL Server MVPhttp://www.insidesql.deHeute schon gebloggt? http://www.insidesql.de/blogs |
 |
|
|
|
|
|