I need to add 3 hours to a date + a time - excel

I have a column where each cell has a date and a time in it
4/12/14 8:35 PM
I want to add 3 hours to the time for each cell.
In the end, it will be: 4/12/14 11:35 PM
What's the quickest way to do this?

consider =A1+3/24 -– simoco
use cell formatting to display full date and time -- nazim

Related

How to calculate the hour between two hour times in Excel?

I have an excel sheet with the following in a row as an example:
'10:00 - 16:00'.. Typically it is HOUR - HOUR2.
I am trying to get the total hours based on this. So 10:00 - 16:00 would be 6 hours. 10:00 to 16:30 will probably be 6.5 hours etc.
Is there an possible way to do this in excel with a formula?
I'm ok with it not doing the overly complex ones (Ones with several hour - hour2 in one column) but it would make it easier if it at least did the ones that are simplistic.
Thanks!
With data in A1, in B1 enter:
=timevalue(RIGHT(A1,5))-timevalue(left(A1,5))
and then apply a time format to B1 to give hours:minutes. To get numeric hours, use:
=24*(TIMEVALUE(RIGHT(A1,5))-TIMEVALUE(LEFT(A1,5)))
You could try:
=TEXT(RIGHT(A1,(LEN(A1)-(FIND("-",A1)+1)))-LEFT(A1,(FIND("-",A1)-2)),"hh:mm:ss")
Results:

Defaulting to PM instead of AM when not adding "AM/PM" to the end of a time formatted cell

Edit: I have since learned that this is only possible with formulas that add 12 hours to the time.
I have a "Time out" column in my Excel timesheet and I would like it to default to PM when I forget to add "PM" manually. I just by habit don't put in PM and it defaults to AM which messes up my formula I have for the "Hours:" column which calculates the difference between the time out and the time in which gets the hours I worked for the day. I was hoping for a way to make it default to PM in the formatting to avoid using extra formulas or complications.
I didn't try it, but maybe you could add a custom format adding 12 hrs to the given time. Alternatively you could add a column (width 0 pt) for calculating the working hours that is adding these 12 hrs?

Excel Categorize Times of day

I am trying to create an excel function that categorizes the time of day.
I have a column of DateTimes, Format: 3/3/2017 13:30 (but can change the format if needed). I need a second column declaring "ON" for the hours 9 pm to 5 am, "AM" for 5 am to 9 am, "BH" for 9 am to 5 pm, and "PM" for the hours 5 pm to 9 pm. I need weekends too but I figure I can pull those manually.
Result would look like (where I have column 1 and need to calculate column 2):
DateTime Time period
3/3/2017 13:30 BH
3/3/2017 17:30 PM
3/4/2017 3:30 ON
3/5/2017 5:30 AM
Make a table with the lower time and expected out put:
Then a simple VLOOKUP:
=VLOOKUP(MOD(A2,1),F:G,2)
We can save a few characters by only testing one end of each range. Once we have tested a value for less than 5 am, we no longer need to test to see if it is greater than 5 am. (The AND( statements aren't necessary.)
=IF(HOUR(A1)<5,"ON",IF(HOUR(A1)<9,"AM",IF(HOUR(A1)<17,"BH",IF(HOUR(A1)<21,"PM","ON"))))
If you want to detect weekends, wrap the whole thing in a weekend test. Two methods presented:
The better approach, suggested by #ScottCraner in the comments:
=IF(weekday(a1,2)>5,"WEEKEND","THE WHOLE THING")
The first argument for weekday( is obviously the date we are testing. The second forces Monday to be the first day of the week, which leaves Sat & Sun as the last two.
Combined with the rest, we would get:
=IF(weekday(a1,2)>5,"WEEKEND",IF(HOUR(A1)<5,"ON",IF(HOUR(A1)<9,"AM",IF(HOUR(A1)<17,"BH",IF(HOUR(A1)<21,"PM","ON")))))
An unnecessarily long, and somewhat fragile approach (breaks in non-English)
=IF(LEFT(TEXT(A1,"ddd"),1)="S","WEEKEND","THE WHOLE THING")
This works because TEXT(A1,"ddd") formats the date as the three-letter day of week. In English, at least, both weekend days starts with an "S", and we use left( to grab that first letter.
Together, it would end up looking like:
=IF(LEFT(TEXT(A1,"ddd"),1)="S","WEEKEND",IF(HOUR(A1)<5,"ON",IF(HOUR(A1)<9,"AM",IF(HOUR(A1)<17,"BH",IF(HOUR(A1)<21,"PM","ON")))))
Just to show a different way:
=IF(NETWORKDAYS(A2,A2),CHOOSE(SUM((({"5:00";"9:00";"17:00";"21:00"}*1)<MOD(A2,1))*1)+1,"ON","AM","BH","PM","ON"),"WEEKEND")
This is an array formula and must be confirmed with ctrl+shift+enter.
Can be extended as you like without getting in trouble of the bracket-limit.
Also like the Scott's answer: this works with times like 17:43. ;)
A little long, but works:
=IF(AND(HOUR(A2)>=9,HOUR(A2)<17),"BH",IF(AND(HOUR(A2)>=17,HOUR(A2)<21),"PM",IF(AND(HOUR(A2)>=5,HOUR(A2)<9),"AM","ON")))

Excel how get number of hours in a time interval?

I have 2 columns with:
Night shift start: 19:00
Night end: 04:00
And I have some date columns with for each day..
Work started: 07:30
Worked ended: 22:00
I want to get the number of hours as a decimal that is between the night shift start and night end. I need to calculate the number of "night shift hours" for worked hours.
From comment: I do not want to get the total number of hours. I want to calculate the number of "night shift hours" and that is hours between 19:00-04:00
=IF(B1-A1 < 0, 1-(A1-B1),( B1-A1))
Assuming that cell A1 contains start, B1 contains end time.
Let me know, if it helps OR errors.
Time without date is not enough to do the subtraction considering the start can be the night before today.
Are you OK to try VBA?
EDIT: The formula is meaningful within 12 hour limit. I will see if it can be made simpler.
Given start time in B5 and end time in C5 this formula will give you the decimal number of hours that fall in the range 19:00 to 04:00
=MOD(C5-B5,1)*24-(C5<B5)*(19-4)-MEDIAN(C5*24,4,19)+MEDIAN(B5*24,4,19)
format result cell as number
just substract the two dates to get the difference in days, and multiply by 24 to get the difference in hours
=(B1-A1)*24
this is correct when both B1 and A1 contain a datetime value, but in case your cells contain just a time value, with no day value, and given that the calculation spans the night (there is a day change in between) you need to add one day to the difference:
=IF(B1<A1,1+B1-A1,B1-A1)*24

Elapsed Days Hours Minutes Excluding Weekends and Holidays Time

This sounds simple but I have been pulling my hair out trying to figure out a solution. Any help before I go bald would be great.
I need a formula which is able to
calculate the duration in (days, hrs, mins) between two date\time values (eg 05/12/2012 5:30 PM and say 07/12/2012 5:45 PM);
excluding weekends and holidays.
I would like the result of the formula to read as follows "e.g 2 Days 0 Hrs and 15 Mins".
Thanks
Link to sample workbook
You can use NETWORKDAYS and NETWORKDAYS.INTL to achieve this
A bit of manipulation is required as these return net whole days:
Use these functions to calculate the number of non workdays, then subtract from the difference between start and end dates
=E3-D3-(NETWORKDAYS.INTL(D3,E3,"0000000")-NETWORKDAYS(D3,E3,$A$16:$A$24))
This returns the working day difference, where 1.0 = 1 day
NETWORKDAYS.INTL(D3,E3,"0000000") calculates whole days between the two dates (no weekends, no holidays)
NETWORKDAYS(D3,E3,"0000000",$A$16:$A$24) calculates whole working days days between the two dates (Sat/Sun weekends, holidays as per your list in $A$16:$A$24)
Difference in non-working days between the two dates.
E3-D3 is time between start and end date/times (1.0 = 1 day)
Use custom number formatting to display thye result in the format you require
d "Days" h "Hours" mm "Mins"
Note: this format won't work for negative values, you will need an alternative for when end date is before start date.
The following formula works like a treat with no additional formatting or manipulation.
To make it more stable I have turned all the holiday dates for UK 2012/13 into ‘Excel Serial Number’ format and placed them in an array bracket.
Replacing the "D5" in the formula with your cell reference for your course or metric "End Date" and "E5" with your course or Metric for "Completion Date".
=IF(E5<D5,"-"&TEXT(D5-E5,"h:mm"),NETWORKDAYS(D5,E5,({40910,41005,41008,41036,41064,41065,41148,41268,41269,41275,41362,41365,41400,41421,41512,41633,41634}))-1-(MOD(E5,1)<MOD(D5,1))&" days "&TEXT(E5-D5,"h:mm"))

Resources