?
Solved

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

Posted on 2008-10-23
4
Medium Priority
?
2,048 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 93

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 93

Accepted Solution

by:
Patrick Matthews earned 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

719 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