Excel Formula Question

Having difficulties with AvCanada Forums, the internet etc.. ask your questions here.

Moderators: sky's the limit, sepia, Sulako, North Shore

Post Reply
User avatar
Grey_Wolf
Rank 7
Rank 7
Posts: 718
Joined: Sat Aug 19, 2006 1:23 pm

Excel Formula Question

Post by Grey_Wolf »

Morning All :mrgreen:

Wondering if anyone out there could help me with an MS Excel Question.

What I would like to do is, set an a formula that counts time between two values of time on different days and spits out a number of hours between the two. Essentially counting "duty rest" to be specific.

I have a formula to count duty time, namely =Sum(End Time+Start Time). I have tried using the same formula for duty rest, but excel spits out the #value! error.

Any help would be greatly appreciated. Thanks & Regards
---------- ADS -----------
 
"A good traveller has no fixed plan and is not intent on arriving." -Lao Tzu
moocow
Rank 7
Rank 7
Posts: 697
Joined: Fri Oct 05, 2007 10:36 pm

Re: Excel Formula Question

Post by moocow »

Check your data range. The #Value! error probably mean there are empty cells somewhere or meaningless data like text.
---------- ADS -----------
 
AuxBatOn
Rank 11
Rank 11
Posts: 3283
Joined: Wed Jan 16, 2008 6:13 pm
Location: North America, sometimes

Re: Excel Formula Question

Post by AuxBatOn »

Let's say you put "01/09/10 11:30" in cell A1 and "01/09/10 23:30" in cell A2, if you put "A2-A1" in cell A3, you will get "12:00" as a return.
---------- ADS -----------
 
Going for the deck at corner
User avatar
Grey_Wolf
Rank 7
Rank 7
Posts: 718
Joined: Sat Aug 19, 2006 1:23 pm

Re: Excel Formula Question

Post by Grey_Wolf »

Thanks Guys

Moocow: I did have empty cells due to the layout of the cells; I have 5 cells set up in a row with start, split start, split end, end, duty. Since the "split" cells are empty, the #value! error would come up.

AuxBatOn: Thanks for pointing out the date format. I changed the cells to it. Problem solved!
---------- ADS -----------
 
"A good traveller has no fixed plan and is not intent on arriving." -Lao Tzu
User avatar
Grey_Wolf
Rank 7
Rank 7
Posts: 718
Joined: Sat Aug 19, 2006 1:23 pm

Re: Excel Formula Question

Post by Grey_Wolf »

One more issue. I have set up the cells in the time format as mentionned by AuxBatOn, the issue now is that Excel doesn't count days between two values.

For example: worked till, let's say 18:00 on day 1, then had 3 days off, then reported at 6:00. Excel seems to only count the hours between 18 and 6 (giving a value of 12:00), but not the extra 72 hours between.

Any Ideas? :?

Thanks! :prayer:
---------- ADS -----------
 
"A good traveller has no fixed plan and is not intent on arriving." -Lao Tzu
User avatar
Grey_Wolf
Rank 7
Rank 7
Posts: 718
Joined: Sat Aug 19, 2006 1:23 pm

Re: Excel Formula Question

Post by Grey_Wolf »

Dabbled more in Excel today. Found out (via Excel Help) that Excel doesn't count more than 24 hours in a difference between times.
---------- ADS -----------
 
"A good traveller has no fixed plan and is not intent on arriving." -Lao Tzu
AuxBatOn
Rank 11
Rank 11
Posts: 3283
Joined: Wed Jan 16, 2008 6:13 pm
Location: North America, sometimes

Re: Excel Formula Question

Post by AuxBatOn »

Make sure you put a date in with a time. Otherwise it will assume today. I was able to make it work yesterday and many times before.
---------- ADS -----------
 
Going for the deck at corner
200hr Wonder
Rank 10
Rank 10
Posts: 2212
Joined: Tue Apr 26, 2005 1:52 pm
Location: CYVR
Contact:

Re: Excel Formula Question

Post by 200hr Wonder »

Grey Wolf,

Time seems to bugger a lot of people up when it comes to Excel. First of all, dates are serialized to simply a number.

For example 10-Apr-2010 is treated as 38816. Time is a decimal factor after it. IE 38816.50 would be 12 noon on 10-Apr-2010. April 11 is 38817.

Once you understand this manipulating dates becomes much easier.

And here is a useless peace of information, Excel is time indexed from January 1st, 1904. Don't ask me why.

Now back to your question, if you wish to know the number of days between two dates you take the difference between the two and you format it as a number. If you wish to not round there formulas for that. For example if your dates are:

4/10/10 8:00 4/11/10 21:00

The difference between them is 1.54. if you wish to know just the number of days and select to show 1 decimal place, Excel will follow proper rounding procedures and round up to 2 days. To get the correct answer 1 you can apply the formula INT which rounds down to the nearest Integer. So =INT(B1-A1) set to show zero decimal places and voila. If you wanted to know the number of hours between a duty day you could simply do this: =(B1-A1)*24 and you can get your hours, 37 in the example.
---------- ADS -----------
 
Cheers,

200hr Wonder
Louis
Rank 8
Rank 8
Posts: 997
Joined: Sun Feb 15, 2004 7:28 pm
Location: CYUL

Re: Excel Formula Question

Post by Louis »

While maybe not directly applicable to your calculations, it may be wise to note that if you start using seconds in there, that some rounding errors with the serial value could mean that what shows as 2010-09-09 11:01:35 in two cells would not return equal as true.
---------- ADS -----------
 
User avatar
Grey_Wolf
Rank 7
Rank 7
Posts: 718
Joined: Sat Aug 19, 2006 1:23 pm

Re: Excel Formula Question

Post by Grey_Wolf »

200Hr Wonder. The INT Formula (B1-A1)*24, works so far. Is there a way to get minutes in there as well?
---------- ADS -----------
 
"A good traveller has no fixed plan and is not intent on arriving." -Lao Tzu
200hr Wonder
Rank 10
Rank 10
Posts: 2212
Joined: Tue Apr 26, 2005 1:52 pm
Location: CYVR
Contact:

Re: Excel Formula Question

Post by 200hr Wonder »

Grey Wolf, see the attached sample workbook. There is a sample there where you can enter Day 1 & Day 2 and it will return Days, Hours, Minutes between the dates and a few sample dates. As with all things in Excel there is many ways to do the same thing, so if you have something else that works, it is not necessary more or less correct.

Cheers,

200hr Wonder

PS Had to zip the file, just unzip to view.
---------- ADS -----------
 
Attachments
Dates Example.xls.zip
(21.69 KiB) Downloaded 221 times
Cheers,

200hr Wonder
User avatar
Grey_Wolf
Rank 7
Rank 7
Posts: 718
Joined: Sat Aug 19, 2006 1:23 pm

Re: Excel Formula Question

Post by Grey_Wolf »

Cool

Here's my "template" file with a few example/numbers put in.

The yellow highlighted cells are the ones I'm having difficulty solving.

Please let me know if you have any questions.

Thanks A Million!
---------- ADS -----------
 
"A good traveller has no fixed plan and is not intent on arriving." -Lao Tzu
200hr Wonder
Rank 10
Rank 10
Posts: 2212
Joined: Tue Apr 26, 2005 1:52 pm
Location: CYVR
Contact:

Re: Excel Formula Question

Post by 200hr Wonder »

Grey Wolf

S12 is the example I gave above, if you change it to the date/time format you get 1/4/00 10:35AM which is correct.

What I recommend is this: =(N17-Q12)*24 set this to be a Number with 1 decimal place and you will get your rest as decimal hours, which from what I understand from the sheet is what you are looking for. In fact I would suggest you should do the same with your duty time. What you are doing is is counting hours in both instances. Now if you must use the 23:30 type of notation you can create a custom mask to display it.

The other suggestion I would make is that you can in a hidden cell create the full date time (it comes form Other Places) because having to key in the entire date/time is just a PITA when you just want to punch in some times and be done with it. Also will save many key punch errors. Then do the mat on the hidden cell.

The other issue I see with this is there is no accounting for rest prior to the 1st. Perhaps that needs to be accounted for?

What is your ultimate goal for this sheet? Send it out to people or just for you? As it stands I see quite a few pitfalls right that could just totally screw the sheet up with just a few key punch errors.
---------- ADS -----------
 
Cheers,

200hr Wonder
User avatar
Grey_Wolf
Rank 7
Rank 7
Posts: 718
Joined: Sat Aug 19, 2006 1:23 pm

Re: Excel Formula Question

Post by Grey_Wolf »

Thanks for the help so far ...

I have converted the "Duty" and "Rest" into number/decimal format. Much easier to work with when calculating/summing at the bottom.

The "Rest" prior to the first is not important for the overall use of the sheet, since the sheet is designed to be used on a month-to-month basis, as opposed to a rolling/sliding window type of file (using LOOKUP functions).

Ultimately, the sheet will be distributed to those at work that might like it; however, I'm trying to make it user friendly.

The date entering is a PITA! Any examples on how to do so? (as suggested with a hidden cell).

Any other pitfalls you can point out would be helpful.

Thanks
---------- ADS -----------
 
"A good traveller has no fixed plan and is not intent on arriving." -Lao Tzu
200hr Wonder
Rank 10
Rank 10
Posts: 2212
Joined: Tue Apr 26, 2005 1:52 pm
Location: CYVR
Contact:

Re: Excel Formula Question

Post by 200hr Wonder »

See Attached
---------- ADS -----------
 
Attachments
Mileage Report Sheet Fixed.xlsx.zip
(19.05 KiB) Downloaded 207 times
Cheers,

200hr Wonder
User avatar
Grey_Wolf
Rank 7
Rank 7
Posts: 718
Joined: Sat Aug 19, 2006 1:23 pm

Re: Excel Formula Question

Post by Grey_Wolf »

Awesome!

Been busy at work, sorry for the delay in the response.

Thanks again 200hr Wonder. If you're ever in YXL Terminal, look for the tall bearded fellow, without glasses, flying for the 'rising sun' company. I'll get you a coffee/tea/hot chocolate! :mrgreen:

Cheers!
---------- ADS -----------
 
"A good traveller has no fixed plan and is not intent on arriving." -Lao Tzu
200hr Wonder
Rank 10
Rank 10
Posts: 2212
Joined: Tue Apr 26, 2005 1:52 pm
Location: CYVR
Contact:

Re: Excel Formula Question

Post by 200hr Wonder »

Will do, alas I use to be based out of YXL, really should update the profile as I have returned to wet coast. Though to be honest I had guessed that your sun was rising due to the types on the sheet.

As for the rest period if you just show it for each day you should be good after all you really just want to make sure that you are legal and have sufficient rest from your previous rest correct?
---------- ADS -----------
 
Cheers,

200hr Wonder
User avatar
Grey_Wolf
Rank 7
Rank 7
Posts: 718
Joined: Sat Aug 19, 2006 1:23 pm

Re: Excel Formula Question

Post by Grey_Wolf »

Yup, Duty Rest is what I want to track. So far the sheet does so and I can see if there any times where it might be close for the "36 hours in 7 Days" clause. Anywho, offer still stands. :wink:
---------- ADS -----------
 
"A good traveller has no fixed plan and is not intent on arriving." -Lao Tzu
Post Reply

Return to “Internet and Computer Help”