excel - How do I calculate hours when there are fractional components -


i trying make spreadsheet calculate hours week. problem having datediff function returns integers getting incorrect results.

function calculatehoursday(strstart string, strend string, intlunch integer) double      dim dblhours double      dblhours = datediff("h", strstart, dateadd("h", 12, strend)) - intlunch      calculatehoursday = dblhours  end function 

if call function "7:00", "2:45", .5 7 when need 7.25. in fact 7 "7:00", "2:45", 0 can see decimal value getting truncated. add 12 hours times can entered without regard am, pm or military time since on 99% (if not 100%) of time times start time , pm end time.

i expecting 7.25 function stated parameters. suggestions?

alex provided correct answer , tbur pointed out bug would've surfaced applied alex's solution.

function calculatehoursday(strstart string, strend string, dbllunch double) double      dim dblhours double      '"n" refers minutes.     dblhours = (datediff("n", strstart, dateadd("h", 12, strend)) / 60) - dbllunch      calculatehoursday = dblhours  end function 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -