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 |
Delinda
Constraint Violating Yak Guru
315 Posts |
Posted - 2009-11-21 : 00:41:32
|
Me have table and data as follow,tTimeTID | TTime-----------------1 | 0230002 | 2000003 | 2230004 | 1030005 | 1530001- My TTime format is 6 digit number.2- 023000 means 230AM3- 200000 means 800PM4- 223000 means 1030PM5- 103000 means 1030AM6- 153000 means 330PMI want to make it my tTime show as follow,TID | TTime-----------------1 | 230AM2 | 800PM3 | 1030PM4 | 1030AM5 | 330PMMe really need help |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-11-21 : 08:29:17
|
[code]select dateadd(hour, TTime / 10000, dateadd(minute, TTime % 10000 / 100, dateadd(second, TTime % 100, 0)))[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-11-21 : 15:00:02
|
[code]DECLARE @Sample TABLE ( TID INT, TTime CHAR(6) )INSERT @SampleSELECT 1, '023000' UNION ALLSELECT 2, '200000' UNION ALLSELECT 3, '223000' UNION ALLSELECT 4, '103000' UNION ALLSELECT 5, '153000'SELECT *, LTRIM(RIGHT(CONVERT(VARCHAR(30), CAST(STUFF(LEFT(TTime, 4), 3, 0, ':') AS DATETIME), 100), 7)) AS Peso, dateadd(hour, TTime / 10000, dateadd(minute, TTime % 10000 / 100, dateadd(second, TTime % 100, 0))) AS khtanFROM @Sample[/code] N 56°04'39.26"E 12°55'05.63" |
|
|
Delinda
Constraint Violating Yak Guru
315 Posts |
Posted - 2009-11-21 : 20:54:37
|
both of you are great |
|
|
|
|
|
|
|