Excel Time addition - excel

First time poster and new joiner.
So I’m having a little difficulty is attempting to take a “lapsed time” with a format of 0:00:00 from a stated time (in this case I’m using a time stamp)
What I would like to achieve is the following.
Let’s say I attain some data from an external source that shows me the lapsed time someone hasn’t been logged In from their expected time. Now unfortunately the time due isn’t readily available so I want to put in A1 (CTRL + shift and ; for my time stamp) and then in B1 I want to minus the lapsed time. And in C1 a subtraction formula that will give me (there or about a the time that should be due to log in)
The issue I’m facing is this, I’ve tried a simple minus, a TIME function and both give a value error
I’m unsure whether firstly the fact that my time stamp being only hours and minutes is an issue but also when I attempt to remove the seconds from the lapsed time it won’t easily format out without manual input from me.
I feel like I’m being stupid here but cannot seem to get say;
14:55 to minus 0:25:00 to give me 14:00 !!
For clarity I have tried to format the time to include seconds but still not use...
Is there an easy way to conver the lapsed time to minutes for easier use of TIME ?

14:55 to minus 0:25:00 to give me 14:00
I think you wanted to say "... to give me 14:30".
Well, you can do subtraction of time values:

Related

Number of minutes in a time range - EXCEL

I have a sheet for tracking my hours at work. We also have a time period between the hours of 07:30 & 18:00 where we can accrue 'flex time'. I want to know from my in and out times, how many hours:minutes I have made in flex.
Please can someone help with the calculation?
The standard way of doing these is to use the overlap formula for two intervals
=max(0,min(end1,end2)-max(start1,start2))
So in your case it would be
=MAX(0,MIN(C2,TIMEVALUE("18:00"))-MAX(B2,TIMEVALUE("7:30")))
If some of your time cells contain strings instead of numbers you would need to check for these. One way of doing it is
=IFERROR(MAX(0,MIN(C2+0,TIMEVALUE("18:00"))-MAX(B2+0,TIMEVALUE("7:30"))),0)
If you ever did a night shift including midnight the formula would need further modification.
Fixed my formula to get correct answers. Bit odd but works now!
=C4+IF(A4-TIME(7,30,0)<0,A4-TIME(7,30,0),0)-IF(B4-TIME(18,0,0)>0,B4-TIME(18,0,0),0)
We take the total time then
if our time starts earlier than flex time starts, we ADD the difference between our start time and flex time, which of course will be a negative number
if our end time ends later than flex time ends, we SUBTRACT the difference between our end time and flex time

Reducing duration by a percentage in excel

I have been racking my brain for hours on how to do this, so I am reaching out to some of you excel experts.
Say you have a duration represented as 1d 14:25:00 and you want to reduce that by a given percent, such as 149.5%, how can this be done?
At first I thought about going down the route of having a cell formatted in time, but when you try and do math against it, it fails.
Then I thought about maybe converting the time down to seconds and working with that, but that seems like it is total pain in the rear. It involves a lot of converting from time to number then back to time to display it. There has to be an easier way.
It depends on how you format the cell to read the Date/Time. If it's represented as a Time, then I believe the best approach is to convert the percentage into a decimal number (i.e 150% = 1.5), then use that in your formula.
However, it also requires applying the cell format to the custom format of [h]:mm:ss to include any times above 24 hours. See the image below for an example.
Time Conversion Example:
The only alternative is a "pain in the rear" - breaking the time down into seconds.
Excel includes built-in functions to convert a Date/Time into HOUR(date), MINUTE(date), and SECOND(date). Unfortunately, getting the number of days requires calculating the difference between two times: DAYS(end_date, start_date). I used this in the example above for the rows titled Conversion.

Attributing values depending of another value w/ VBA ? Excel 2010

First of all, sorry if it already exists but I can't find the words in English to describe rapidly my question, hence I don't know how to search for it. Skip to third paragraph if you only need the question.
I'm using Excel to build a complete document about my work hours (arrived at, finished at, if I've been late and of how long was I late, overtime, etc etc).
I'm using VBA to smooth this task.
My workplace cuts everything into quarter of hours, which means that if you're late by one minute, you'll lose 15 minutes. If you work overtime for 14 minutes, it won't be seen as overtime. If I point at 07:45 (I'm using 24H format, not AM/PM) I'm fine. If I do it at 07:46 it'll be counted as 08:00. Same with 16:14, it'll show up as 16:00 (details are shown but on the corrected sheet used for salary, it'll show this way). If I do it at 16:15 I've confirmed my 15 minutes of overtime.
So while I could do some workarounds, what I've got in mind is shitcode, really. I'd like to know a good (clean) way to do this : I want for every timestamps I input to be cut in degressive quarter of hours (for instance, I want 17:12 to show up as 17:00 or 08:57 as 08:45).
Thanks for your help, if you didn't understand something or doubt about something I've said, it's probably because of the way I explained it, please ask whatever's needed :)
Update 01: Values are indeed Time processed by Excel, not Strings looking like a timestamp.
Update 02: Solved by #FunThomas with TimeSerial-command and some explanations. Thanks, I hope this can be of help for future reference, however I lack the words to write a better title for this problem.
Assuming that you data is really time (and not a string that looks like time) and is stored in Cell A1, you can use a formula like this:
=TIME(HOUR(A1), INT(MINUTE(A1)/15) * 15, 0)
The time-command gets three paramater (hour, minute, second).
The hour-part is simple.
For the minute, we make an integer division by 15 (resulting in values from 0..3) and multiply it back with 15 (to get 0, 15, 30 or 45).
The second is simply set to 0.
Update:
As VBA-function:
Function roundTime(t As Date) as date
roundTime = TimeSerial(Hour(t), Int(Minute(t) / 15) * 15, 0)
End Function

Repair incorrectly formatted time 'hh:nn:ss' when h=0

I'm doing a report which calculates people's time to determine their pay. We pull reports from our servers and paste them into Excel to do the calculations. I have run into an issue when pulling the data: if the time they logged in for was less than an hour our formula is not working:
=IF(E159="","",((HOUR(E159)+(MINUTE(E159)+(SECOND(E159)/60))/60)))
This gives an error (#value) if the time is :34:15, but if it's 00:34:15 then it's fine.
Formatting the cell does not appear to work.
I'd like to go through this column and add the 00 to all values missing it, and I need some help or guidance from there.
Another question on SO looks like it may help, but I'm unsure on how to use it.
Assuming that The tiem is in cell E159 from your above formula, you can append a 0 to the start of the time. This will fix all the times that have the hour missing and won't affect the other lines.
="0"&E159
You can then replace all of the E159 references in your original formula with this edit so that it looks like this:
=IF(E159="","",((HOUR("0"&E159)+(MINUTE("0"&E159)+(SECOND("0"&E159)/60))/60)))
While it's hard to read, it does the trick.
While that answers you question.. I think that there is a better way to achieve this formula.
It looks like the end result you're looking for is the time converted to hours, with mulutes and seconds as a decimel to the next hour. You can achieve this by doing:
=E159*24
Which will give you the same result as your original formula.
And then to combine that with my first answer to get a formula that looks like:
=("0" & E159)*24
This approach is much easier to read / edit and provides the same output.
Why This Works
Excel stores all dates as whole numbers, and all times as a decimel % to a day.
So when Excel is stores 12 hours it saves it as .5 because it is half of a day.
By dividing the time output by 24 we are converting the entire time value down from a % of day to a % of hours.

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