Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 21
Default Formula to give date and time

Hi Everyone!!

Looking for help on a formula.

I have s apreadsheet

In Column A is a date and time 12/04/07 16:00
In column B I need to have a formula to add 4 hours to column B
but..... this is the difficult part that I am not sure is
possible....... this formula needs to take in to account days and
times - 9am - 5pm Monday - Friday.

So I need 12/04/0716:00
With formula of 9am-5pm would be 13/04/07 12:00

Any help would be great
Any questions please ask.

Thanks everyone

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Formula to give date and time

Angela,

For a date/time in cell A2, use this formula in cell B2:

=A2+IF((A2-INT(A2)+4/24)*24 17,IF(WEEKDAY(A2,2)=5,2,0)+20/24,4/24)

and copy down to match your times.

HTH,
Bernie
MS Excel MVP


"Angela1979" wrote in message
oups.com...
Hi Everyone!!

Looking for help on a formula.

I have s apreadsheet

In Column A is a date and time 12/04/07 16:00
In column B I need to have a formula to add 4 hours to column B
but..... this is the difficult part that I am not sure is
possible....... this formula needs to take in to account days and
times - 9am - 5pm Monday - Friday.

So I need 12/04/0716:00
With formula of 9am-5pm would be 13/04/07 12:00

Any help would be great
Any questions please ask.

Thanks everyone



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default Formula to give date and time

"Angela1979" wrote...
....
In Column A is a date and time 12/04/07 16:00
In column B I need to have a formula to add 4 hours to column B


Presumably you mean add 4 hours to column A.

. . . this formula needs to take in to account days and
times - 9am - 5pm Monday - Friday.

So I need 12/04/07 16:00
With formula of 9am-5pm would be 13/04/07 12:00


B2: =A2+IF(HOUR(A2)<13,1/6,IF(WEEKDAY(A2,2)=5,2,0)+5/6)

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 353
Default Formula to give date and time

Fractions are way easier (not mention slightly more accurate) than the
decimals I've somehow gotten into the habit of using over the years...
Just one teeny thing with your formula, tho... If the start date/time is 1
pm, your formula returns 9 the next morning, instead of 5 pm.

=A2+IF(AND(HOUR(A2)<=13,MINUTE(A2)=0),1/6,IF(WEEKDAY(A2,2)=5,2,0)+5/6)

fixes that and is way better than my original - :-)

"Harlan Grove" wrote:

"Angela1979" wrote...
....
In Column A is a date and time 12/04/07 16:00
In column B I need to have a formula to add 4 hours to column B


Presumably you mean add 4 hours to column A.

. . . this formula needs to take in to account days and
times - 9am - 5pm Monday - Friday.

So I need 12/04/07 16:00
With formula of 9am-5pm would be 13/04/07 12:00


B2: =A2+IF(HOUR(A2)<13,1/6,IF(WEEKDAY(A2,2)=5,2,0)+5/6)


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default Formula to give date and time

BoniM wrote...
....
Just one teeny thing with your formula, tho... If the start
date/time is 1 pm, your formula returns 9 the next morning,
instead of 5 pm.

....

If the 4 hours later in B2 is the END of the period begun in A2, I'd
agree, but there's a simpler approach.

=A2+IF(MOD(A2,1)-"13:00:01"<0,1/6,IF(WEEKDAY(A2,2)=5,2,0)+5/6)

If B2 is the beginning of the next period after the period beginning
in A2, I'll stick with 13:00 - 09:00 next workday.



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 353
Default Formula to give date and time

Ah ha! Got it... assumption I didn't even know Id made - that it was
something due back in four hours, rather than something new needed to begin.
Well either way, you've got it covered beautifully.

"Harlan Grove" wrote:

BoniM wrote...
....
Just one teeny thing with your formula, tho... If the start
date/time is 1 pm, your formula returns 9 the next morning,
instead of 5 pm.

....

If the 4 hours later in B2 is the END of the period begun in A2, I'd
agree, but there's a simpler approach.

=A2+IF(MOD(A2,1)-"13:00:01"<0,1/6,IF(WEEKDAY(A2,2)=5,2,0)+5/6)

If B2 is the beginning of the next period after the period beginning
in A2, I'll stick with 13:00 - 09:00 next workday.


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 903
Default Formula to give date and time

Question was resubmitted by poster see
Add 4 hours (only if between 9am-5pm)
http://groups.google.com/groups?thre...oglegroups.com


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a decimal hours to a starting time to give a finishing tim Peter Rooney Excel Discussion (Misc queries) 3 March 21st 07 01:48 PM
Give RELEVANT responses to questions. DO NOT give usless list pmartin Excel Worksheet Functions 2 July 6th 06 06:08 PM
Calculating days & time left from start date/time to end date/time marie Excel Worksheet Functions 7 December 7th 05 02:36 PM
I need to measure hours between two events(time/date) to give me . iartis Excel Worksheet Functions 2 May 12th 05 02:12 AM
Give File Time to update Pivot Table when started bij Macro Jasper Excel Discussion (Misc queries) 0 April 27th 05 01:30 PM


All times are GMT +1. The time now is 08:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"