Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default How do I subtract 8 business hours from a date/time value?

I am trying to subtract 8 hours from a date/time. What I need to do is to
capture that lead time using only weekdays, and working hours of 8am-5pm.

For example:

Date/Time
6/23/2008 9:18AM (Monday)

Subtracting 8 hours from this scenario would give me
6/20/2008 10:18AM (friday)
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 913
Default How do I subtract 8 business hours from a date/time value?

On Thu, 19 Jun 2008 12:40:01 -0700, drew
wrote:

I am trying to subtract 8 hours from a date/time. What I need to do is to
capture that lead time using only weekdays, and working hours of 8am-5pm.

For example:

Date/Time
6/23/2008 9:18AM (Monday)

Subtracting 8 hours from this scenario would give me
6/20/2008 10:18AM (friday)


If you by weekdays simply mean Mondays through Fridays, you can try
this:

=A1-8/24-15/24*(HOUR(A1)<16)-2*AND(HOUR(A1)<16,WEEKDAY(A1,2)=1)

Hope this helps/ Lars-Åke

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default How do I subtract 8 business hours from a date/time value?

This does help. Thanks!!
One more request. If I want to add another column that subtracts business
hours from the column we just created... where in the formula would I input
the hours I want to subtract? And , would it still be business hours?

Thanks again!!

"Lars-Ã…ke Aspelin" wrote:

On Thu, 19 Jun 2008 12:40:01 -0700, drew
wrote:

I am trying to subtract 8 hours from a date/time. What I need to do is to
capture that lead time using only weekdays, and working hours of 8am-5pm.

For example:

Date/Time
6/23/2008 9:18AM (Monday)

Subtracting 8 hours from this scenario would give me
6/20/2008 10:18AM (friday)


If you by weekdays simply mean Mondays through Fridays, you can try
this:

=A1-8/24-15/24*(HOUR(A1)<16)-2*AND(HOUR(A1)<16,WEEKDAY(A1,2)=1)

Hope this helps/ Lars-Ã…ke


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 913
Default How do I subtract 8 business hours from a date/time value?

Refering to the formula below

=A1-8/24-15/24*(HOUR(A1)<16)-2*AND(HOUR(A1)<16,WEEKDAY(A1,2)=1)

the 8 in 8/24 is the number of business hours to subtract
the 15 is the number of "non working hours"
the 16 (in two places) is the start of working hour plus the number of
business hours to subtract.

So to generalise the formula bit:

=A1-A4/24-(24-(A3-A2))/24*(HOUR(A1)<(A2+A4))-2*AND(HOUR(A1)<(A2+A4),WEEKDAY(A1,2)=1)

where
the start of work hours (8) is in A2
the end of work hours (17) is in A3
the business hours to subtract is in A4
(A2, A3, A4 should not be formatted as TIME, just as NUMBER.)

Hope this helps / Lars-Åke

On Thu, 19 Jun 2008 13:28:08 -0700, drew
wrote:

This does help. Thanks!!
One more request. If I want to add another column that subtracts business
hours from the column we just created... where in the formula would I input
the hours I want to subtract? And , would it still be business hours?

Thanks again!!

"Lars-Åke Aspelin" wrote:

On Thu, 19 Jun 2008 12:40:01 -0700, drew
wrote:

I am trying to subtract 8 hours from a date/time. What I need to do is to
capture that lead time using only weekdays, and working hours of 8am-5pm.

For example:

Date/Time
6/23/2008 9:18AM (Monday)

Subtracting 8 hours from this scenario would give me
6/20/2008 10:18AM (friday)


If you by weekdays simply mean Mondays through Fridays, you can try
this:

=A1-8/24-15/24*(HOUR(A1)<16)-2*AND(HOUR(A1)<16,WEEKDAY(A1,2)=1)

Hope this helps/ Lars-Åke



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default How do I subtract 8 business hours from a date/time value?

Lars, I tried this formula with the values in A2-A4 as you suggested, but it
is not quite there yet. Maybe an even easier way to go, is instead of
subtracting 8 hours, can we subtract 12?

A1: 6/23/2008 9:00 AM
a2: 8
a3: 17
a4: 12

The formula gave me 6/20/2008 6:00 AM as the value, but in actuality is
should be 6/19/2008 3:00 PM.

Thanks!

"Lars-Ã…ke Aspelin" wrote:

Refering to the formula below

=A1-8/24-15/24*(HOUR(A1)<16)-2*AND(HOUR(A1)<16,WEEKDAY(A1,2)=1)

the 8 in 8/24 is the number of business hours to subtract
the 15 is the number of "non working hours"
the 16 (in two places) is the start of working hour plus the number of
business hours to subtract.

So to generalise the formula bit:

=A1-A4/24-(24-(A3-A2))/24*(HOUR(A1)<(A2+A4))-2*AND(HOUR(A1)<(A2+A4),WEEKDAY(A1,2)=1)

where
the start of work hours (8) is in A2
the end of work hours (17) is in A3
the business hours to subtract is in A4
(A2, A3, A4 should not be formatted as TIME, just as NUMBER.)

Hope this helps / Lars-Ã…ke

On Thu, 19 Jun 2008 13:28:08 -0700, drew
wrote:

This does help. Thanks!!
One more request. If I want to add another column that subtracts business
hours from the column we just created... where in the formula would I input
the hours I want to subtract? And , would it still be business hours?

Thanks again!!

"Lars-Ã…ke Aspelin" wrote:

On Thu, 19 Jun 2008 12:40:01 -0700, drew
wrote:

I am trying to subtract 8 hours from a date/time. What I need to do is to
capture that lead time using only weekdays, and working hours of 8am-5pm.

For example:

Date/Time
6/23/2008 9:18AM (Monday)

Subtracting 8 hours from this scenario would give me
6/20/2008 10:18AM (friday)

If you by weekdays simply mean Mondays through Fridays, you can try
this:

=A1-8/24-15/24*(HOUR(A1)<16)-2*AND(HOUR(A1)<16,WEEKDAY(A1,2)=1)

Hope this helps/ Lars-Ã…ke






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 913
Default How do I subtract 8 business hours from a date/time value?

Sorry drew, the formula I provided was not as general as I stated.
It only works if the starting time is on the same weekday or on the
weekday before the end time.
That is alway the case if the business hours to subtract is less than
or equal to one working day.

Lars-Åke

On Wed, 25 Jun 2008 11:21:00 -0700, drew
wrote:

Lars, I tried this formula with the values in A2-A4 as you suggested, but it
is not quite there yet. Maybe an even easier way to go, is instead of
subtracting 8 hours, can we subtract 12?

A1: 6/23/2008 9:00 AM
a2: 8
a3: 17
a4: 12

The formula gave me 6/20/2008 6:00 AM as the value, but in actuality is
should be 6/19/2008 3:00 PM.

Thanks!

"Lars-Åke Aspelin" wrote:

Refering to the formula below

=A1-8/24-15/24*(HOUR(A1)<16)-2*AND(HOUR(A1)<16,WEEKDAY(A1,2)=1)

the 8 in 8/24 is the number of business hours to subtract
the 15 is the number of "non working hours"
the 16 (in two places) is the start of working hour plus the number of
business hours to subtract.

So to generalise the formula bit:

=A1-A4/24-(24-(A3-A2))/24*(HOUR(A1)<(A2+A4))-2*AND(HOUR(A1)<(A2+A4),WEEKDAY(A1,2)=1)

where
the start of work hours (8) is in A2
the end of work hours (17) is in A3
the business hours to subtract is in A4
(A2, A3, A4 should not be formatted as TIME, just as NUMBER.)

Hope this helps / Lars-Åke

On Thu, 19 Jun 2008 13:28:08 -0700, drew
wrote:

This does help. Thanks!!
One more request. If I want to add another column that subtracts business
hours from the column we just created... where in the formula would I input
the hours I want to subtract? And , would it still be business hours?

Thanks again!!

"Lars-Åke Aspelin" wrote:

On Thu, 19 Jun 2008 12:40:01 -0700, drew
wrote:

I am trying to subtract 8 hours from a date/time. What I need to do is to
capture that lead time using only weekdays, and working hours of 8am-5pm.

For example:

Date/Time
6/23/2008 9:18AM (Monday)

Subtracting 8 hours from this scenario would give me
6/20/2008 10:18AM (friday)

If you by weekdays simply mean Mondays through Fridays, you can try
this:

=A1-8/24-15/24*(HOUR(A1)<16)-2*AND(HOUR(A1)<16,WEEKDAY(A1,2)=1)

Hope this helps/ Lars-Åke





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
Time/Date subtract 24 hours ET902 Excel Discussion (Misc queries) 4 September 12th 06 02:47 PM
Date and Time Response- before/during/after Business hours ECLynn Excel Discussion (Misc queries) 1 September 7th 06 06:46 PM
How do I add 12 business hours to the current date/time? [email protected] Excel Worksheet Functions 1 May 10th 06 01:18 AM
How do I add 12 business hours to the current date/time? [email protected] Excel Worksheet Functions 0 May 10th 06 12:45 AM
Time and Business Hours Brett Excel Worksheet Functions 1 November 23rd 05 08:20 PM


All times are GMT +1. The time now is 11:15 PM.

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"