• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 339
  • Last Modified:

Best way to calculate total hours between two text times?


I have two time fields. One being the beginning time and other being the ending time

Both times are in 24 hour format and in text format


Beginning            Ending
10:22                     15:38

I want to know what is the best way in calculating the time in-between in hours?

eg: a 330 minutes difference would be noted as 5.5 hours, etc

Thank you for your help!
3 Solutions
If you use text that looks like numbers in an arithmetic formula, it is converted into a real number. So you could calculate the hours difference as:

The business with MOD allows you to span midnight.

The multiplication by 24 is because times are stored as fractions of a day, so 12:00 noon is 0.5
Glenn RayExcel VBA DeveloperCommented:
If the two text values are in cells A2 (beginning) and B2 (ending), then insert the following formula in cell C2:

You then need to format that cell using "h:mm" to convert the value into hours and minutes.
Right-click on the cell, click Format Cells, select "Custom" from the menu on left, enter "h:mm" in the Type box (do not use quotes.

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

If you want to display a blank until both times have been entered, you might use:

COUNTA returns the number of cells containing text or numbers.
Glenn RayExcel VBA DeveloperCommented:
Noting byundt's point about crossing midnight:

If that is a possibility, then my original formula should be changed to the following:

Shanan212Author Commented:
Thank you!<br /><br />byundt's solution provides 1.78 hours rather than 1:47 (1hr 47 mins) that Glen was able to provide.<br /><br />I require 1.78 hours to find salary.<br /><br />Regardless, valuable lessons from Glen as well!<br /><br />Thank you all!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now