Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default subtracting dates in an IF statement

Dear All

Please, what is wrong with this formula?

=IF(I6="01/01/2099",$Q$2-H6,I6-H6)
....copied down from M6 to M50.

I have two columns of dates (H6,50, I6,50) and a reference date in Q2. All
cells formatted as date (14/03/2001)
The result column is M6,50 (formatted as number | general)
If date in I6 is 01/01/2099, I want to do Q2-H6, if not then I6-H6
If date in I7 is 01/01/2099, I want to do Q2-H7, if not then I7-H7, etc

Formula doesn't seem to recognise the "01/01/2099", but statement valid (no
syntax error)
For example, I7 does contain the date 01/01/2099 and H7 is 12/06/2008, but
formula (in M7) calculates the wrong option (I7-H7=33075 days). Wrong logic?

I am using Excel 2003.


Many thanks, Phil




  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default subtracting dates in an IF statement

=IF(I6=Datevalue("01/01/2099"),$Q$2-H6,I6-H6)


"Phil C" wrote:

Dear All

Please, what is wrong with this formula?

=IF(I6="01/01/2099",$Q$2-H6,I6-H6)
....copied down from M6 to M50.

I have two columns of dates (H6,50, I6,50) and a reference date in Q2. All
cells formatted as date (14/03/2001)
The result column is M6,50 (formatted as number | general)
If date in I6 is 01/01/2099, I want to do Q2-H6, if not then I6-H6
If date in I7 is 01/01/2099, I want to do Q2-H7, if not then I7-H7, etc

Formula doesn't seem to recognise the "01/01/2099", but statement valid (no
syntax error)
For example, I7 does contain the date 01/01/2099 and H7 is 12/06/2008, but
formula (in M7) calculates the wrong option (I7-H7=33075 days). Wrong logic?

I am using Excel 2003.


Many thanks, Phil





  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default subtracting dates in an IF statement

Joel

Excellent! Many thanks for your prompt response.

Phil


"Joel" wrote in message
...
=IF(I6=Datevalue("01/01/2099"),$Q$2-H6,I6-H6)


"Phil C" wrote:

Dear All

Please, what is wrong with this formula?

=IF(I6="01/01/2099",$Q$2-H6,I6-H6)
....copied down from M6 to M50.

I have two columns of dates (H6,50, I6,50) and a reference date in Q2.
All
cells formatted as date (14/03/2001)
The result column is M6,50 (formatted as number | general)
If date in I6 is 01/01/2099, I want to do Q2-H6, if not then I6-H6
If date in I7 is 01/01/2099, I want to do Q2-H7, if not then I7-H7, etc

Formula doesn't seem to recognise the "01/01/2099", but statement valid
(no
syntax error)
For example, I7 does contain the date 01/01/2099 and H7 is 12/06/2008,
but
formula (in M7) calculates the wrong option (I7-H7=33075 days). Wrong
logic?

I am using Excel 2003.


Many thanks, Phil







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 from Different Dates Steve M Excel Worksheet Functions 0 May 27th 08 12:44 PM
Subtracting Dates Dilly Excel Discussion (Misc queries) 10 January 28th 08 04:00 PM
Subtracting Dates Malik Excel Discussion (Misc queries) 4 October 1st 07 10:44 AM
Subtracting dates? Bill R Excel Worksheet Functions 1 August 15th 05 05:37 AM
Subtracting dates: 8/31/05-8/1/05? dstock Excel Discussion (Misc queries) 1 July 26th 05 04:04 PM


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