Solved

Convert Float to Time Stamp with No Date and must return days as hours - URGENT

Posted on 2008-10-23
4
2,045 Views
Last Modified: 2010-04-21
I have field in a table which is Float, it contains a Duration Value.
I need this to be returned as a Time Value.

For Example I can get it to return as a TIme Stamp....as Below using 108 or 114
which gives me HH:MM:SS:mmm

select convert(Varchar,CAST(NetDur AS DATETIME),108)as NetDur
From
CliSpend

Result looks like : 00:11:27:997

But if I look at this value using
select convert(Varchar,CAST(NetDur AS DATETIME),120)as NetDur
From
CliSpend

Result looks like : 1900-01-03 00:11:27

So actually my duration is 3 days, eleven mins and twenty seven seconds.....

I need my time stamp to then include the number of days in hours....
so it should be 72 hours.....

I need the result to be 72:11:27:997
This value as float is displayed as 2.00796296296296 of which I've attempted my convert on.

Please can someone help this is URGENT.

0
Comment
Question by:EHardie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 22785895
EHardie said:
>>I need the result to be 72:11:27:997

Based on your example, shouldn't that be 48:11:27:997?  After all, it looks like scant more than *2* days
have passed...

Regards,

Patrick
0
 

Author Comment

by:EHardie
ID: 22785956
Ok possibly I'm just assuming as imy other results are
1900-01-01 00:00:00 for example so  assumed 3 days.....for the 3rd of the month.
Either way I'm just trying to achieve the hours to reflect yes such as 48 hours or 72 hours so the time is presented to add on 24 hours per day ......

Any idea's ?
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 22786555
SELECT CONVERT(varchar, DATEDIFF(hour, '1900-01-01', CONVERT(datetime, NetDur))) + SUBSTRING(CONVERT(varchar, CONVERT(datetime, NetDur), 114), 3, 10)
FROM CliSpend
0
 

Author Closing Comment

by:EHardie
ID: 31509193
You rock , thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question