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 |
|
jjmoss1234
Starting Member
11 Posts |
Posted - 2011-02-16 : 11:31:24
|
| Hi ThereI have 2 colums in a table (table_1) which show hours and minutesso column 1 may show 23 and column 2 may show 7how can I convert this to get a result of 23:07 as in a time element?Thanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-02-16 : 11:42:31
|
| declare @col1 int, @col2 intselect @col1=23, @col2=7select convert(char(12),DATEADD(hour, @col1,dateadd(minute,@col2,0)),108)MadhivananFailing to plan is Planning to fail |
 |
|
|
jjmoss1234
Starting Member
11 Posts |
Posted - 2011-02-16 : 12:03:45
|
| Thankyou very much MadhivananMuch appreciated! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-02-16 : 12:04:13
|
quote: Originally posted by jjmoss1234 Thankyou very much MadhivananMuch appreciated!
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
jjmoss1234
Starting Member
11 Posts |
Posted - 2011-02-16 : 12:08:52
|
| How do I get a whole table of different hrs and mins to convert?Not just 23 and 7?I.e. what do I set the variables as? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-02-16 : 16:20:03
|
select convert(char(8), DATEADD(hour, col1, dateadd(minute, col2, 0)), 108) from table1 N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|
|
|
|