February 11, 2014 at 11:58 pm
Hi All,
I want to convert time into hours as per below format. Please guide.
For example – 2:15:00 would be computed as 2.25 HRS or 6:30:00 would show as 6.5 HRS.
Kindly help how can i do this.
February 12, 2014 at 2:35 am
DECLARE @t AS TIME = '2:15:00.000';
SELECT
DATEPART(hour, @t) +
(
DATEPART(minute, @t) * 60 +
DATEPART(second, @t) + DATEPART(millisecond, @t) * 1.0/1000
) * 1.0/3600 AS FormattedTime
___________________________
Do Not Optimize for Exceptions!
February 12, 2014 at 3:38 am
abhas (2/11/2014)
Hi All,I want to convert time into hours as per below format. Please guide.
For example – 2:15:00 would be computed as 2.25 HRS or 6:30:00 would show as 6.5 HRS.
Kindly help how can i do this.
Solutions will depend upon the datatype of your 'time' column. Can you post a CREATE TABLE - it doesn't have to contain anything more than your 'time' column - and a few INSERTS please?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
February 12, 2014 at 4:20 am
Thanks Milos. 🙂
🙂 🙂 🙂
Its working. Thanks a lot
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply