Thread: Leap Year
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default Leap Year

"BadBoy" wrote:
If February is in cell O8 and its a leap year, put the number 29 in cell
S8,
if not a leap year, put 0 and if any other month regardless if its a leap
year or not, put the number 29.


=if(or(O8<"February",day(date(S8,3,0))=29),29,0)


if any of the months mentioned below are in cell
O8, place the number 0 in cell O8, otherwise put 31 in cell O8


=If (or(O8={"February","September","April","June","Nov ember"}),0,31)

Note: I assume you mean to put this formula in some other cell, not O8
[sic].


FYI, both formulas can be written without IF(), which can be useful if you
are concerned about function nesting.

=29*or(O8<"February",day(date(S8,3,0))=29)

=31*and(O8<{"February","September","April","June" ,"November"})

Note the change to AND(<) in the latter formula. Alternatively, you can
keep the original logic and use the following arcane formulation:

=31-31*or(O8={"February","September","April","June","N ovember"})


----- original message -----

"BadBoy" wrote in message
...
Good morning folks,

I have two problems perhaps you may be able to help with.

1) - In the formula below, I wonder if you can help with the following;

If February is in cell O8 and its a leap year, put the number 29 in cell
S8,
if not a leap year, put 0 and if any other month regardless if its a leap
year or not, put the number 29.

=IF(O8="February",DAY(DATE(S8,3,0)),29)



2) - In the formula below, if any of the months mentioned below are in
cell
O8, place the number 0 in cell O8, otherwise put 31 in cell O8

=If (O8="February","September","April","June","Novembe r",0,31)

Any help you may offer will be much appreciated.

-Bad