Time Calculation and Conversion

griggsbgsu

New Member
Joined
Mar 7, 2002
Messages
6
Okay, I'm fairly good with Excel, but I'm no expert. I've ran into a wall and I can't figure out what to do, so hopefully someone can help. Feel free to email me: saragrigsby@yahoo.com

Here is my problem. I have a worksheet setup where I keep track of the hours that I work and the pay I receive. It's worked quite well for the most part, but there is one case that doesn't work.

I have it setup so I enter my clock-in time and my clock-out time and it calculates the number of hours I worked and then calculates my pay and so on. The problem is with calculating the hours that I've worked. I enter my clock-in time in one cell, my clock-out time in another, and here is the formula I use to calculate the hours: =TEXT(B2-A2, "hh:mm"). I enter my times in this format: 5:30 PM for example.

Here is where I run into problems. The formula works fine when my hours are in the same day, for example: 5:30 PM to 10:30 PM. BUT, if my hours are say: 5:30 PM to 12:30 AM, then I get an error in my formula. This happens when my clock-out time runs past 12AM.

I've gotten suggestions to use the 24 hour time format: 15:30, but I'd rather use the standard 12 hour format. I've searched everywhere. I really hope someone has some suggestions for me. Thank you :)
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
On 2002-03-08 16:08, griggsbgsu wrote:
Okay, I'm fairly good with Excel, but I'm no expert. I've ran into a wall and I can't figure out what to do, so hopefully someone can help. Feel free to email me: saragrigsby@yahoo.com

Here is my problem. I have a worksheet setup where I keep track of the hours that I work and the pay I receive. It's worked quite well for the most part, but there is one case that doesn't work.

I have it setup so I enter my clock-in time and my clock-out time and it calculates the number of hours I worked and then calculates my pay and so on. The problem is with calculating the hours that I've worked. I enter my clock-in time in one cell, my clock-out time in another, and here is the formula I use to calculate the hours: =TEXT(B2-A2, "hh:mm"). I enter my times in this format: 5:30 PM for example.

Here is where I run into problems. The formula works fine when my hours are in the same day, for example: 5:30 PM to 10:30 PM. BUT, if my hours are say: 5:30 PM to 12:30 AM, then I get an error in my formula. This happens when my clock-out time runs past 12AM.

I've gotten suggestions to use the 24 hour time format: 15:30, but I'd rather use the standard 12 hour format. I've searched everywhere. I really hope someone has some suggestions for me. Thank you :)

I don't think that the 24 hour format will work for you either (you'll get a negative number). What I suggest, which I'm sure that you'll find to be a pain, is to enter not only the time but the date. I can't see another way around this, sorry.

Somethink like this:

3/8/2002 5:30 PM 3/9/2002 1:00 AM

-rh
 
Upvote 0
Actually, if you just add 24 to your early morning times it will work (but this would be the 24-hour format you so dread). For example,

6:30 PM 25:00

25:00 being 1 am. Otherwise I think you're going to have to use the date.

Hope I've at least given you some ideas,

Russell
 
Upvote 0
On 2002-03-08 16:08, griggsbgsu wrote:
Okay, I'm fairly good with Excel, but I'm no expert. I've ran into a wall and I can't figure out what to do, so hopefully someone can help. Feel free to email me: saragrigsby@yahoo.com

Here is my problem. I have a worksheet setup where I keep track of the hours that I work and the pay I receive. It's worked quite well for the most part, but there is one case that doesn't work.

I have it setup so I enter my clock-in time and my clock-out time and it calculates the number of hours I worked and then calculates my pay and so on. The problem is with calculating the hours that I've worked. I enter my clock-in time in one cell, my clock-out time in another, and here is the formula I use to calculate the hours: =TEXT(B2-A2, "hh:mm"). I enter my times in this format: 5:30 PM for example.

Here is where I run into problems. The formula works fine when my hours are in the same day, for example: 5:30 PM to 10:30 PM. BUT, if my hours are say: 5:30 PM to 12:30 AM, then I get an error in my formula. This happens when my clock-out time runs past 12AM.

I've gotten suggestions to use the 24 hour time format: 15:30, but I'd rather use the standard 12 hour format. I've searched everywhere. I really hope someone has some suggestions for me. Thank you /board/images/smiles/icon_smile.gif

This formula should work for you:

=TEXT(IF(B1<A1,1-A1+B1,B1-A1),"hh:mm")

Regards,
 
Upvote 0
Thanks for the formula, but i entered it and corrected the cell numbers to my correct cell and I still get an error. So, I don't know i'm lost.
 
Upvote 0
On 2002-03-08 16:23, griggsbgsu wrote:
Thanks for the formula, but i entered it and corrected the cell numbers to my correct cell and I still get an error. So, I don't know i'm lost.

Cell A1 equals your start time and B1 equals your end time. What was your error (it worked fine for me)? What values were you using to generate the error?
 
Upvote 0
Good one, Barry! That one works for me. B1 should be your second date's cell, and A1 the first. Try it again.

-rh
 
Upvote 0
Okay I'll give you an example from my sheet.

A1=Time In
B1=Time Out
C1=Formaula: =TEXT(B1-A1, "h:mm")

Okay here is a situation where it works fine.
A1 - 3:15 PM
B1 - 11:22 PM
C1 - Formula result: 8:07
Cool, that works!

Here is a situation where the formula doesn't work.
A1 - 3:50 PM
B1 - 12:38 AM
C1 - Formaul result: VALUE!
Okay, that doesn't work.
These are right from my sheet so if they work for someone else I must be doing something really wrong.
 
Upvote 0
On 2002-03-08 16:30, griggsbgsu wrote:
Okay I'll give you an example from my sheet.

A1=Time In
B1=Time Out
C1=Formaula: =TEXT(B1-A1, "h:mm")

Okay here is a situation where it works fine.
A1 - 3:15 PM
B1 - 11:22 PM
C1 - Formula result: 8:07
Cool, that works!

Here is a situation where the formula doesn't work.
A1 - 3:50 PM
B1 - 12:38 AM
C1 - Formaul result: VALUE!
Okay, that doesn't work.
These are right from my sheet so if they work for someone else I must be doing something really wrong.

Put this formula in C1

=TEXT(IF(B1<A1,1-A1+B1,B1-A1),"hh:mm")
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,541
Latest member
iparraguirre89

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top