MS-Excel Negative times - excel

I'm writing a spreadsheet for a shop manager. What it does is keep track of the number of hours a worker has worked.
So you enter times for Monday-Sunday, and then an adjustment - e.g. if they work 40/40/40/32 hours for the month, then you would have an adjustment of -2/-2/-2/+6 to bring the worker to the 38 hour week that he's being paid for. Some (most) weeks may be adjusted for overtime. The spreadsheet then totals the hours.
This spreadsheet is supposed to just be a self-calculating version of a paper form.
It needs to match the paper form as it has to be substituted for the old form which is given to some other member of the company (pay clerk, I don't know; I'm not rebuilding their whole system, just replacing a form)
I'm having trouble entering a negative time in the adj field - the field has a [h]:mm formatting. and when i enter a negative time (e.g. -2:00) it displays an error, saying "incorrectly formatted equation", with the suggestion that if I was entering a string then I should prefix with a apostrophe.
How do I overcome this?

Tools - Options - Calculation - 1904 date system
Check this box to use the 1904 (Mac) date system and you will be able to use negative dates and times. I'm not sure how this will effect existing spreadsheets, so maybe someone else can speak to that.

According to Excel...
"Dates and Times that are negative appear as ########"
Doesn't sound like you're going to be able to do that with an auto-summation formula. You'll have to set the formatting as none and just type it in (which defeats the purpose).

I am solving the same problem. Setting for date formatting "1904" is necessary for both below described solution.
You can enter an equation as a result of predeceasing cells like C5-C4-C3 (check out-check in-standard working time). The result is negative and it will be displayed like -1:15 and you can further process it.
Second way was already described above - to put into the requested cell a negative decimal value as a fraction of "1". "1,000"=24 hours, "0,5"=12 hours, "0,01"= 14 minutes, "0,041667"=1 hour. You have to find the correct decimal numbers first.

Related

Subtracting times across a day in excel

I am working on the capstone project in of the Google Career Certificate in Data Analytics. I am using Microsoft Excel. I have to calculate the ride length based on the start and end ride times. I've inputted the formula =F2(end time)-D2(start time) which returns the ride length. Going through my entire list I have some areas where the start time is like 11pm and the end time is 1am and this is returning ###### because it is a negative number with the regular formula. I've found a modified formula that can kind of do the conversion I am looking for but it is still a bit problematic. The modified formula is =(F2-D2+(F2<D2))*24 and it seems to give an accurate ride length if I reformat the answer to number. The issue is the rest of my data is in time format and the modified ones are in number format. If I convert the number values to time, the ride length values are inaccurate.
It is tricky to make the numeric value change as well due to me using a formula. I can correct them one by one after I save Excel and it no longer stores the numbers as the formula, but there are lots of data points to change and that would be time consuming. I'm hoping to find a more concise way to solve this problem. Maybe with a better formula.
[Snippet of the chart 1
Just like everything in life, there are multiple ways to achieve things. I would have formatted the date and time into a single cell; but. if you're gathering the data from another source, that's understandable.
A simple IF statement here will work. IF the days are one apart, then take '1' day off the starting time, else do your original formula:
=IF(E4-C4=1,F4-(D4-1),F4-D4)

Excel function for First Row and Last Row of group

I have a gate keeping report with a number of entry/exit times for an employee over a 24hr period.
I need another formula to go into I40 which is the difference between the first entry time - last entry time for each employee eg. I40 = F50 - D40.
Dont worry about the formula regarding the subtraction of dates as I have this. I really just need the formula that will allow me to get the Last Exit time cell and the First Entry time cell for each employee.
The best way is to always store datetime values (ie, 2018-05-24 13:454) instead of just the times. You could still display it as a time by changing the cell's formatting to a time format.
Shortcut to Number Formatting options: Ctrl+1
There are many advantages, including that "regular math" will still work even if a shift starts in a different day than it ends.
If you must stick with only times, you can still calculate it correctly (up to a 23.9-hour shift) with an IF statement to add a day if the returned value is negative.
For example, if your existing formula works for same-day shift, and is:
=F50-D40
...then you could change it to:
=IF(F50-D40<0,F50+1-D40,F50-D40)
More Information:
Office.com : How to use dates and times in Excel
Office.com : Add or subtract time (Excel)
EDIT:
Looking at your question again, perhaps I misunderstood what you were trying to ndo. It's a little unclear, but you mention the fist and last times.
If you mean the "earliest and latest", you can get those using MIN and MAX. If the crossing-midnight is an issue here too, you'll need to see my first suggestion above, or else add a "helper column" to determine which times are before which.
Storing datetime is still best and this all would have been avoided.
try the below to get the difference in hours.
=(E50+F50)-(C40+D40)

Conditional Formatting with Time through Formula

I'm trying to highlight the time based on the folowing rules
If the time is lower than 7:30 be closer to red
Otherwise if the time is closer to 8:05 get close to green
In this sheet:
I guess it's easier to explain with the following illustration:
You should get the basic idea of what I'm trying to accomplish with the formulars in the formatting rule picture. That one however doesn't work.
Any ideas what would be the proper way to format this rule?
On the left side for value write 0,31 and on the right side write 0,34.
To get the correct value, that is corresponding to the correct time, simply select the time in Excel, using the Time() formula, press Ctrl+1 and select Number. You will see the correct number for the time.
Also found a way, albeit this is more of a workaround:
You can enter the values as a raw number in format of AB:CD:EF (or depending on the time format you are using) and excel will automatically format the rule somehow with decimal signs, although this really is more of a workaround rather than answer to the actual question
You can use "industrial minutes", minutes to a base of 100 industrialseconds. Then you can use standard decimal values.
In excel you simple multiply time values by 24 to get to that. Then 30 minutes are 0.5 of an hour.
For the conditional formating use a 3-Color scale and set the middlepoint to number 7.5 and a lighter green.

Adding numeric value based on tickbox in Sharepoint formula

I'm trying to create a simple leave planner application using Sharepoint. I've got the bulk of it working but I'm going back to do edge cases now like Bank Holidays and half days. So I've added a checkbox column and if ticked, I want it to deduct 0.5 from the total value (half-day). The formula that's working for the full days is:
=(DATEDIF(dateFrom,dateTo,"D"))-INT(DATEDIF(dateFrom,dateTo,"D")/7)*2-IF((WEEKDAY(dateTo)-WEEKDAY(dateFrom))<0,2,0)+1
So I just created another two columns called shalfday and ehalfday. If they're ticked then deduct 0.5 from the total (If dates match and both ticked then deduct 0.5 still).
I've tried playing round with things like
-IF([shalfday],"0.5")
and other variants as google results are not being too kind this morning but they're returning #NAME? variables.
Any pointers on the syntax or what I should be looking at?
I would suggest:
-IF([shalfday],0.5,0)
Since you are trying to subtract you should work with integers and not strings (i removed the quotation marks).
I ended up doing this another way. I instead asked the user to specify how many half days were in their leave in another site column and used this suffix in the formula. It also got rid of the validation check to make sure the user wasn't taking two half days on 1 days leave.
New site column called 'Total Half Days' set to number, default value of 0;
Appended to original formula:
-([Total Half Days]/2)+1
Full formula:
=(DATEDIF(dateFrom,dateTo,"D"))-INT(DATEDIF(dateFrom,dateTo,"D")/7)*2-IF((WEEKDAY(dateTo)-WEEKDAY(dateFrom))<0,2,0)-([Total Half Days]/2)+1

Converting TEXT that represents NEGATIVE TIME value to a number or time value for adding (Excel)

I've got a spreadsheet (Office 2007 version of Excel) full of text entries that are negative time values, example "-0:07" as in an employee took 7 mins less to complete a job than expected. I need to perform mathematical calculations on these entries and am looking for a more elegant formula/method than I've come up with so far.
I know about 1904 date system and * or / by 24 to convert back and forth, the problem is getting a formula that will recognize the text entry as a negative time value.
I've tried value(), *1, which both work on the text fields if the number is positive, but the "-" seems to mess those up. Even paste-special/add fails to recognize these as numbers.
Here's what I came up with that gets the job done, but it's just so ugly to me:
=IF(LEFT(E5,1)="-",((VALUE(RIGHT(E5,LEN(E5)-1)))*-1.0),VALUE(E5))
Obviously my text entry is in cell E5 in this example.
This works, so I'm not desperate for a solution, but for educational purposes (and smaller code) I'd like to know if there's a better way to this. Does anyone have a suggestion for something shorter, easier?
Thanks.
P.S. - an interesting tidbit here, I use Excel at work, but not at home, so I uploaded a sample spreadsheet to Google Docs, and it actually handles the Value() command on those entries properly. Weird, huh?
Thanks again for any suggestions.
Excel doesn't handle time spans in cells. It only deals with time. When you do "00:07" it is then converted to 0.0048611 which is the same as Jan 1st 1900 12.07 am. So if you did 2 minutes minus 7 minutes it would give at best 11.55pm.
The way you do it is the only way.

Resources