View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David Biddulph[_2_] David Biddulph[_2_] is offline
external usenet poster
 
Posts: 8,651
Default year formula returning incorrect value

Your problem is that you forgot that YEAR returns the 2008 as a number, not
as an Excel date. You should have the cell formatted as general or number,
but instead you formatted the cell as a date in yyyy format. The number
2008 would be Excel's representation of a date 2008 days on from the
beginning of January 1900. 2008 days on gets you to 30th June 1905, and you
have asked it to display that number in yyyy format.

If all you wanted to do was to display 4/24/2008 in yyyy format, you didn't
need the YEAR() function, you could merely have formatted the cell (B2
itself, or a cell containing the formula =B2) to display that way.

Either use =YEAR() and format as General or Number
Or use formatting as yyyy
Or use =TEXT(B2,"yyyy") to return 2008 as text
Or use =--TEXT(B2,"yyyy") as another way to return 2008 as a number

If you try to mix and match without remembering whether your cell contains a
number or an Excel date, you can readily get confused, as you found out.
--
David Biddulph

"dbdewitt" wrote in message
...
As I understand it, the YEAR formula should return the year to which the
formula relates. I have a date of 4/24/2008 in a cell (let's say it's in
cell B2), when I enter the formula (let's say in cell A2) "=YEAR(B2)", the
result is 1905 where the result should be 2008. Can someone tell me what
I'm
missing?