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

Hi all,

I have two columns: one is the "date time" a task began and the other is the
"date time" the task ended. I want to measure the difference in hours.

For example, in A1 I have "6/28/2008 15:44" and in B1 I have "7/1/2008
16:51" These cell values are based on a function
[=IF(AND(ISNUMBER(F66),ISNUMBER(G66)),F66+G66,"")] that has brought together
separate date and time values from other columns.

To find the difference between these two cells, I tried simply subtracting
(which gave me another date-time value) and I tried the following formula
based on another spreadsheet I've used
[=IF(AND(ISNUMBER(A1),ISNUMBER(B1)),B1-A1,"")] but this gives me the
differences between the two times, but doesn't account for the difference
between dates.

Any thoughts?

Thanks,
Nathan

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,389
Default subtracting date/time

Simple subtracting the two numbers, as in =b1-a1 *does* work. It's your
format which is causing the problems.

You need to:
1. Use a format which includes the date as well as the time, or
2. Use a format of [hh]:mm which will display more than 24 hours.

Regards,
Fred.

"Nathan" wrote in message
...
Hi all,

I have two columns: one is the "date time" a task began and the other is
the
"date time" the task ended. I want to measure the difference in hours.

For example, in A1 I have "6/28/2008 15:44" and in B1 I have "7/1/2008
16:51" These cell values are based on a function
[=IF(AND(ISNUMBER(F66),ISNUMBER(G66)),F66+G66,"")] that has brought
together
separate date and time values from other columns.

To find the difference between these two cells, I tried simply subtracting
(which gave me another date-time value) and I tried the following formula
based on another spreadsheet I've used
[=IF(AND(ISNUMBER(A1),ISNUMBER(B1)),B1-A1,"")] but this gives me the
differences between the two times, but doesn't account for the difference
between dates.

Any thoughts?

Thanks,
Nathan


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 192
Default subtracting date/time

=DATEDIF(A1,A2,"M")
returns the difference in dates in months.

"D" is days
"Y" is years
"YD" is days excluding years
"YM" is months excluding years
"MD" is days excluding months and years

--
-SA


"Nathan" wrote:

Hi all,

I have two columns: one is the "date time" a task began and the other is the
"date time" the task ended. I want to measure the difference in hours.

For example, in A1 I have "6/28/2008 15:44" and in B1 I have "7/1/2008
16:51" These cell values are based on a function
[=IF(AND(ISNUMBER(F66),ISNUMBER(G66)),F66+G66,"")] that has brought together
separate date and time values from other columns.

To find the difference between these two cells, I tried simply subtracting
(which gave me another date-time value) and I tried the following formula
based on another spreadsheet I've used
[=IF(AND(ISNUMBER(A1),ISNUMBER(B1)),B1-A1,"")] but this gives me the
differences between the two times, but doesn't account for the difference
between dates.

Any thoughts?

Thanks,
Nathan

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default subtracting date/time

Try this formula...

=24*(B1-A1)

Rick


"Nathan" wrote in message
...
Hi all,

I have two columns: one is the "date time" a task began and the other is
the
"date time" the task ended. I want to measure the difference in hours.

For example, in A1 I have "6/28/2008 15:44" and in B1 I have "7/1/2008
16:51" These cell values are based on a function
[=IF(AND(ISNUMBER(F66),ISNUMBER(G66)),F66+G66,"")] that has brought
together
separate date and time values from other columns.

To find the difference between these two cells, I tried simply subtracting
(which gave me another date-time value) and I tried the following formula
based on another spreadsheet I've used
[=IF(AND(ISNUMBER(A1),ISNUMBER(B1)),B1-A1,"")] but this gives me the
differences between the two times, but doesn't account for the difference
between dates.

Any thoughts?

Thanks,
Nathan


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,420
Default subtracting date/time

Just use =B1-A1 and format as [h]:mm

--
__________________________________
HTH

Bob

"Nathan" wrote in message
...
Hi all,

I have two columns: one is the "date time" a task began and the other is
the
"date time" the task ended. I want to measure the difference in hours.

For example, in A1 I have "6/28/2008 15:44" and in B1 I have "7/1/2008
16:51" These cell values are based on a function
[=IF(AND(ISNUMBER(F66),ISNUMBER(G66)),F66+G66,"")] that has brought
together
separate date and time values from other columns.

To find the difference between these two cells, I tried simply subtracting
(which gave me another date-time value) and I tried the following formula
based on another spreadsheet I've used
[=IF(AND(ISNUMBER(A1),ISNUMBER(B1)),B1-A1,"")] but this gives me the
differences between the two times, but doesn't account for the difference
between dates.

Any thoughts?

Thanks,
Nathan





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 64
Default subtracting date/time

Thanks Fred. This worked.

"Fred Smith" wrote:

Simple subtracting the two numbers, as in =b1-a1 *does* work. It's your
format which is causing the problems.

You need to:
1. Use a format which includes the date as well as the time, or
2. Use a format of [hh]:mm which will display more than 24 hours.

Regards,
Fred.

"Nathan" wrote in message
...
Hi all,

I have two columns: one is the "date time" a task began and the other is
the
"date time" the task ended. I want to measure the difference in hours.

For example, in A1 I have "6/28/2008 15:44" and in B1 I have "7/1/2008
16:51" These cell values are based on a function
[=IF(AND(ISNUMBER(F66),ISNUMBER(G66)),F66+G66,"")] that has brought
together
separate date and time values from other columns.

To find the difference between these two cells, I tried simply subtracting
(which gave me another date-time value) and I tried the following formula
based on another spreadsheet I've used
[=IF(AND(ISNUMBER(A1),ISNUMBER(B1)),B1-A1,"")] but this gives me the
differences between the two times, but doesn't account for the difference
between dates.

Any thoughts?

Thanks,
Nathan



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default subtracting date/time

I am trying to make this calculation work using the response above. When I
enter '=a2-a1' into cell a3 the result returned is '#VALUE!' (a value used
in this formula is of the wrong data type).

Format used for cells a1 and a2 is 'm/d/yyyy hh:mm'. Format used in cell
a3 is [hh]:mm.

I can't see why this won't work. Any suggestions?



"Bob Phillips" wrote:

Just use =B1-A1 and format as [h]:mm

--
__________________________________
HTH

Bob

"Nathan" wrote in message
...
Hi all,

I have two columns: one is the "date time" a task began and the other is
the
"date time" the task ended. I want to measure the difference in hours.

For example, in A1 I have "6/28/2008 15:44" and in B1 I have "7/1/2008
16:51" These cell values are based on a function
[=IF(AND(ISNUMBER(F66),ISNUMBER(G66)),F66+G66,"")] that has brought
together
separate date and time values from other columns.

To find the difference between these two cells, I tried simply subtracting
(which gave me another date-time value) and I tried the following formula
based on another spreadsheet I've used
[=IF(AND(ISNUMBER(A1),ISNUMBER(B1)),B1-A1,"")] but this gives me the
differences between the two times, but doesn't account for the difference
between dates.

Any thoughts?

Thanks,
Nathan




  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,389
Default subtracting date/time

Your problem is that either a1 or a2 (or both) is text, not numbers. They
may look like dates and times, but they are text.

The easy way to tell is to try reformatting the cell (to any other
numeric/date/time format). If it doesn't change, you've got text.

The easy way to fix it, is to simply re-enter the numbers.

Regards,
Fred.

"Navy Guy" wrote in message
...
I am trying to make this calculation work using the response above. When I
enter '=a2-a1' into cell a3 the result returned is '#VALUE!' (a value
used
in this formula is of the wrong data type).

Format used for cells a1 and a2 is 'm/d/yyyy hh:mm'. Format used in cell
a3 is [hh]:mm.

I can't see why this won't work. Any suggestions?



"Bob Phillips" wrote:

Just use =B1-A1 and format as [h]:mm

--
__________________________________
HTH

Bob

"Nathan" wrote in message
...
Hi all,

I have two columns: one is the "date time" a task began and the other
is
the
"date time" the task ended. I want to measure the difference in hours.

For example, in A1 I have "6/28/2008 15:44" and in B1 I have "7/1/2008
16:51" These cell values are based on a function
[=IF(AND(ISNUMBER(F66),ISNUMBER(G66)),F66+G66,"")] that has brought
together
separate date and time values from other columns.

To find the difference between these two cells, I tried simply
subtracting
(which gave me another date-time value) and I tried the following
formula
based on another spreadsheet I've used
[=IF(AND(ISNUMBER(A1),ISNUMBER(B1)),B1-A1,"")] but this gives me the
differences between the two times, but doesn't account for the
difference
between dates.

Any thoughts?

Thanks,
Nathan





  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 121
Default subtracting date/time

Hi Rick,

How can the formula you advised be modified to exclude weekends? Also is it
possible to exclude holidays as well?

Ed

"Rick Rothstein (MVP - VB)" wrote:

Try this formula...

=24*(B1-A1)

Rick


"Nathan" wrote in message
...
Hi all,

I have two columns: one is the "date time" a task began and the other is
the
"date time" the task ended. I want to measure the difference in hours.

For example, in A1 I have "6/28/2008 15:44" and in B1 I have "7/1/2008
16:51" These cell values are based on a function
[=IF(AND(ISNUMBER(F66),ISNUMBER(G66)),F66+G66,"")] that has brought
together
separate date and time values from other columns.

To find the difference between these two cells, I tried simply subtracting
(which gave me another date-time value) and I tried the following formula
based on another spreadsheet I've used
[=IF(AND(ISNUMBER(A1),ISNUMBER(B1)),B1-A1,"")] but this gives me the
differences between the two times, but doesn't account for the difference
between dates.

Any thoughts?

Thanks,
Nathan



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
Subtracting Date/Time Sapphyre Excel Discussion (Misc queries) 4 August 21st 07 01:42 AM
Subtracting time in date format Collcat Excel Worksheet Functions 0 November 11th 04 04:44 PM
Subtracting time in date format Collcat Excel Worksheet Functions 1 November 10th 04 09:40 PM
Subtracting time in date format Collcat Excel Worksheet Functions 1 November 10th 04 08:42 PM
Subtracting time in date format Collcat Excel Worksheet Functions 1 November 10th 04 04:45 PM


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