| Author |
Topic |
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-03-28 : 15:27:12
|
| In my GCSOSUBJECTS table, i need to do an update to the SVCTIME column based on data in the Servetime column. SVCTIME is a datetime value (column is all NULL at this time). The values in Servetime look like:1654102116282310all represent time of day. How do i (or do i even) cast those values in my update (Update GCSOSUBJECTS set SVCTIME=CAST(ServeTimeas DATETIME)? <-----obviously not workingThanksj |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-03-28 : 15:29:52
|
My error reads:Msg 242, Level 16, State 3, Line 1The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.The statement has been terminated.when usingUPDATE gcsosubjects SET ROLE='R', subjecttype='P', comments=generalcomments+'. '+typeservicecomments, DBA=substring(CorpOrDBA,1,40), entered=servedate, feesearned=servicecost, svcdate=servedate, servedby=SERVER, svctime=CAST(ServeTime AS DATETIME) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-28 : 15:30:23
|
| convert(datetime,STUFF(Servetime,3,0,':'))------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-03-28 : 15:31:16
|
| thank you |
 |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-03-28 : 15:33:13
|
| Ok, plz clarify what the "stuff" is doing. i can see that it is being told to put the ":" in the 3rd position, but what is the "0," for? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-28 : 15:35:26
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-28 : 15:45:09
|
quote: Originally posted by WJHamel Ok, plz clarify what the "stuff" is doing. i can see that it is being told to put the ":" in the 3rd position, but what is the "0," for?
third argument states number of characters it needs to delete from stringi've given 0 as we dont need to delete anything but just needs to insert ':' at 3rd position------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-03-28 : 15:58:32
|
| thanks again. much appreciated. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-28 : 16:08:33
|
| welcomeAs suggested by Brett...you can get these information easily by refering to books online------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|