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 |
|
devisetti
Starting Member
30 Posts |
Posted - 2008-05-08 : 03:45:56
|
| HiI have TIME stored in the column asstime-----16:12:0016:14:0000:00:0016:12:0002:18:00Required output :16121614I need to get its as in 24 hrs (not required seconds)Ex:16:12I am also require without semicolon Ex:1612Many Thanks in advance |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-05-08 : 03:51:30
|
| select convert(char(2),substring(stime,1,2)) + convert(char(2),substring(stime,4,2)) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-08 : 03:52:49
|
If time is stored as varchar (and time only)SELECT REPLACE(LEFT(sTime, 5), ':', '')If time is stored as datetimeSELECT REPLACE(CONVERT(VARCHAR(5), sTime, 108), ':', '') E 12°55'05.25"N 56°04'39.16" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-08 : 03:56:00
|
| Is this for display purpose? If yes, its better to do this in your front end application.ANd if you want really to do it in SQL Server,try thi:-SELECT LEFT(REPLACE(CONVERT(varchar(10),DateColumn,108),':',''),4) FROM YourTable |
 |
|
|
devisetti
Starting Member
30 Posts |
Posted - 2008-05-08 : 04:04:01
|
| Thanks very much guys. Its working fine. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-05-08 : 04:26:21
|
| IF you use front end application, do this formation thereIf you use datetime columnselect datepart(hour,col)*100+datepart(minute,col) from your_tableMadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-08 : 04:29:05
|
Will that include leading zero if time is before 10 am? E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|
|
|