| Author |
Topic |
|
dseb
Starting Member
7 Posts |
Posted - 2012-03-13 : 22:30:52
|
| Hey everyone,I have a table of which one of the columns has data converted into seconds. I'm trying to get this data converted to Hours but find it very confusing because...In that column one row may have 25200;39600;57600;and the next25200;39600;57600;All times represented in seconds. Which I want displayed in Hours. For example that 1st row should read 7;11;16 (military time). How can I use this column in my query and convert that data into hours?ThxdSEB |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-13 : 22:41:06
|
just convert to hour ? what about minute / seconds ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-13 : 22:49:35
|
| why is value stored in delimited format? have you heard about normalisation and first normal form?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-13 : 22:51:26
|
[code]-- sample tabledeclare @sample table( col varchar(100))-- sample datainsert into @sample (col) select '25200;39600;57600'insert into @sample (col) select '21600;25200;28800'-- Queryselect col, col2 = stuff(hr, 1, 1, '')from @sample s cross apply ( select ';' + datename(hour, dateadd(second, convert(int, Data), 0)) from dbo.fnParseList(';', col) -- http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033 for xml path ('') ) h (hr)-- Result/*col col2----------------- -------25200;39600;57600 7;11;1621600;25200;28800 6;7;8*/[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
dseb
Starting Member
7 Posts |
Posted - 2012-03-13 : 23:42:15
|
Only need the hour. just want all those numbers divided by 3600.quote: Originally posted by khtan just convert to hour ? what about minute / seconds ? KH[spoiler]Time is always against us[/spoiler]
dSEB |
 |
|
|
dseb
Starting Member
7 Posts |
Posted - 2012-03-13 : 23:43:06
|
I don't even know what 'delimited format means'quote: Originally posted by visakh16 why is value stored in delimited format? have you heard about normalisation and first normal form?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
dSEB |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-13 : 23:46:41
|
what you have is delimited formatdelimiter = ";"this is delimited format "25200;39600;57600;" KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
dseb
Starting Member
7 Posts |
Posted - 2012-03-13 : 23:48:12
|
| Thx guys but you all talking tom me in a foreign languagedSEB |
 |
|
|
dseb
Starting Member
7 Posts |
Posted - 2012-03-13 : 23:49:46
|
| I wish I knew why but that's how the developer set that column... Converting it would of been alot easier if it wasn't for thatdSEB |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-13 : 23:50:44
|
do try the query that i have posted KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|