Thread: Date/Time
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David Biddulph[_2_] David Biddulph[_2_] is offline
external usenet poster
 
Posts: 8,651
Default Date/Time

Go through your formula a stage at a time.

For any date in February 2008 in A1, =DATE(YEAR(A1),MONTH(A1)+1,0) will
return 29th Feb.
=DATE(YEAR(A1),MONTH(A1)+1,1) would return the first day of the fiollowing
month, hence 1st March.
=DATE(YEAR(A1),MONTH(A1)+1,0) is one day before that, which is 29th
February.

All that is fairly academic, because *any* non-zero number is treated as
boolean TRUE, so when you feed that into your NOT function you get FALSE.

You have then fed that FALSE in as the first argument of your IF statement,
and the result you have asked for when the condition is FALSE is zero.

That's why it's not working as you had hoped. Other contributors have
suggested various ways of asking the right question of Excel, and thus
getting the answer you were looking for.
--
David Biddulph

"cmatera" wrote in message
...
Trying to determine if the date and the time in a cell are the last
day of the month, and if that's the case I want to perform a certain
operation.

Here's what I have so far:

=IF(NOT(DATE(YEAR(A1),MONTH(A1)+1,0)),1,0)

A1 is 2/29/08

My formula returns 0, I would expect this to return a 1 as 2/29/08 IS
the last day of February...
Any ideas why this might not be working?

Thanks

Chris