Solved

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

Posted on 2008-10-23
4
2,035 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now