Solved

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

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

615 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