View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
TheQuickBrownFox TheQuickBrownFox is offline
external usenet poster
 
Posts: 8
Default Dates and If Function

On Sun, 24 May 2009 09:18:36 +0100, "Roger Govier"
<roger@technology4unospamdotcodotuk wrote:

Hi Ginger

If you are using 05 Apr 2009 in the cell, then the comparison should be
05-04-2009.
However, when you have the date within quotes, it is Text, whereas the dates
in your columns, although appearing like text, are stored internally as
serial numbers.
You need to coerce the Text values in your formula to numbers, by placing
the double unary minus in front of them

=IF(OR(B12<--"5-4-2009", B12<--"7-5-2009", "Y","N")

An alternative, which makes the Date quite explicit is to use the date
function Date(Year, Month, Day)
=IF(OR(B12<DATE(2009,4,5), B12<DATE(2009,5,7), "Y","N")



Is there a code segment that is good for testing for leap years so that
a February calendar can be properly sized/adjusted? You seem extremely
date function knowledgeable.