-1

I'm currently working on a work/time log in a Google Spreadsheet. I'm doing some calculations on how much time I've spent working.

I have a cell containing the number of worked hours represented in a "Time value" number.

E.g. 13:30 hours is represented as 0.559. And I want to represent it as 13,5.

In the cell's function I can do HOUR(0.559) to get the hours. But I want to use my custom function (due to otherwise very long expressions in the cell), like HoursToDecimal(0.559)

Now, I cannot use the HOUR() function in my function because it says its not defined? How can I use it?

function HoursToDecimal(hours_in)
{
  return (INT(hours_in)*24+HOUR(hours_in)+MINUTE(hours_in)/60);
}
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
mrmclovin
  • 1,113
  • 3
  • 13
  • 35

1 Answers1

0

I don't understand how your custom function is supposed to work. GApps stores date/time values as days and fractions of days. If you put a time, such as 13:30, in a cell, google will display it as a time, but will internally convert it to a fraction of a day ( 13.5 / 24 = 0.5625 )

To convert this to hours, just multiply by 24:

hoursworked = timeworked * 24;

Round and/or truncate to your liking.

HardScale
  • 971
  • 1
  • 7
  • 18
  • Thanks for clearing that up for me. It was simple. I didnt understand how GApps was storing time values. – mrmclovin Jan 14 '13 at 12:57