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 |
|
arch88
Starting Member
1 Post |
Posted - 2011-09-26 : 03:21:59
|
Hi,In my table the time is stored as int. For eg, 223007. I need to convert it to 10:30:07 PM. What is the simplest way in which i can achieve this?Please help!  |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-26 : 04:12:45
|
| [code]DECLARE @in intSET @in =223007SELECT RIGHT(CONVERT(varchar(30),DATEADD(ss,@in%10,DATEADD(mi,((@in%10000)/100),DATEADD(hh,@in/10000,0))),109),15)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-09-26 : 11:04:45
|
| Always use datetime datatype and do formation at front end application.DECLARE @in intSET @in =223007select right(convert(varchar(30),convert(datetime,STUFF(stuff(@in,5,0,':'),3,0,':')),9),15)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|