Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Cast or Convert Seconds to Hours

Status
Not open for further replies.

williadn48

Programmer
Oct 27, 2006
29
US
I exec a stored proc thru a CR. The stored proc returns a field called secondselapsed. How do I convert the secondselapsed to hours and display on the report?
 
Use my FAQ:

faq767-3543

Replace the datediff("s",{Orders.Order Date}, currentdate) with your field from the SP.

-k
 
I neglected to mention that I will then need to use the hours in a calculation. Volume/Hours = Productivity.

Should I convert the seconds first to hours then do the division or do the division using seconds (which I tried first but got erroneous results) then convert?
 
Try:

if {table.seconds} <> 0 then
{table.volume/int((({table.seconds}/60)/60))
else
0

This assumes that you want just the hours, not the fraction of hours, otherwise use.

if {table.seconds} <> 0 then
{table.volume/(({table.seconds}/60)/60)
else
0

You can also use /3600 instead.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top