Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Calculating diff between date/ time only between certain hours

I am trying to calculate the difference in hours between a date/time range
but only the hours in a certain range.

1/27/10 4:49 1/27/10 11:32

I am trying to find the diff in hours only between 6:00 and 23:59, any hours
that fall outside of that time frame should not be counted. Each calculation
will have different dates so if there is a way to do this without specifying
the date that would be great!

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 135
Default Calculating diff between date/ time only between certain hours

GMv1 -

If your start date is in A4 and your end date is in B4, then you can do this:

=MOD(B4,1)-IF(MOD(A4,1)<0.25,0.25,MOD(A4,1))

This works becase date/times are stored as numbers. The date portion is the
integer piece, and the time is stored as the decimal piece. MOD pulls pulls
the remainder after removing all multiples of 1 (which in this case returns
the fraction piece of the date, which is the time). So MOD(B4,1) is just the
end time.

The start time portion just says if the time is less than 6AM (.25 = 1/4
day), then use .25 instead of the time (MOD(A4,1).
--
Daryl S


"GMv1" wrote:

I am trying to calculate the difference in hours between a date/time range
but only the hours in a certain range.

1/27/10 4:49 1/27/10 11:32

I am trying to find the diff in hours only between 6:00 and 23:59, any hours
that fall outside of that time frame should not be counted. Each calculation
will have different dates so if there is a way to do this without specifying
the date that would be great!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Calculating diff between date/ time only between certain hours

Thank you this solution worked. I have another scenario that I have been
unable to solve editing the formula you supplied.
1/27/10 4:49 1/27/10 11:32

I am trying to find the diff in hours only between 8:00 and 17:00 Monday to
Friday only, any hours that fall outside of that time frame should not be
counted. Each calculation will have different dates so if there is a way to
do this without specifying the date that would be great!

Thanks again for all of your help thus far!

"Daryl S" wrote:

GMv1 -

If your start date is in A4 and your end date is in B4, then you can do this:

=MOD(B4,1)-IF(MOD(A4,1)<0.25,0.25,MOD(A4,1))

This works becase date/times are stored as numbers. The date portion is the
integer piece, and the time is stored as the decimal piece. MOD pulls pulls
the remainder after removing all multiples of 1 (which in this case returns
the fraction piece of the date, which is the time). So MOD(B4,1) is just the
end time.

The start time portion just says if the time is less than 6AM (.25 = 1/4
day), then use .25 instead of the time (MOD(A4,1).
--
Daryl S


"GMv1" wrote:

I am trying to calculate the difference in hours between a date/time range
but only the hours in a certain range.

1/27/10 4:49 1/27/10 11:32

I am trying to find the diff in hours only between 6:00 and 23:59, any hours
that fall outside of that time frame should not be counted. Each calculation
will have different dates so if there is a way to do this without specifying
the date that would be great!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,389
Default Calculating diff between date/ time only between certain hours

Use:
=(INT(B1)-INT(A1))*18+(MOD(B1,1)-MAX(MOD(A1,1),TIME(6,0,0)))*24

Regards,
Fred

"GMv1" wrote in message
...
I am trying to calculate the difference in hours between a date/time range
but only the hours in a certain range.

1/27/10 4:49 1/27/10 11:32

I am trying to find the diff in hours only between 6:00 and 23:59, any
hours
that fall outside of that time frame should not be counted. Each
calculation
will have different dates so if there is a way to do this without
specifying
the date that would be great!


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 806
Default Calculating diff between date/ time only between certain hours

Hello,

I wrote a UDF for that:
http://sulprobil.com/html/count_hours.html

Regards,
Bernd


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Calculating diff between date/ time only between certain hours

This worked perfectly. Thank you!

"Bernd P" wrote:

Hello,

I wrote a UDF for that:
http://sulprobil.com/html/count_hours.html

Regards,
Bernd
.

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
[NEWBIE] date/time diff Jon Excel Discussion (Misc queries) 4 June 26th 09 10:44 PM
difference of date/time only calculating workingdays/hours Susanne Excel Worksheet Functions 4 February 5th 09 01:42 PM
calculating time for late hours Tim Excel Worksheet Functions 1 May 28th 08 01:31 AM
calculating timesheet, time-in/time-out = total hours & minutes, . Steve Lindsay Excel Worksheet Functions 13 November 8th 06 03:45 PM
Calculating time, hours and minutes arrowpilot Excel Discussion (Misc queries) 1 October 21st 06 12:04 AM


All times are GMT +1. The time now is 09:46 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"