return last four characters in a cell

V

viilis

I have cells containing dates in different formats:

01/01/04
2-3 June 2004
August 2003

How can I extract the last four (or two) characters to just get th
years
 
V

VILLABILLA

Hi I know that following function works with this format:

01/01/04

If this date is shown in cell A1 use the TEXT function like this:
TEXT(A1,"YY")

If you enter this formula in another cell that cell will show 04

You'll have to see how it works with your different date formats...

I hope it will work out

regard
 
A

Aladin Akyurek

If the target entries are all true dates...

=YEAR(A1)

where A1 houses a target entry, should suffice.
 
N

Norman Harker

Hi viilis!

With different formats of which some are dates and some text:

Try:

=IF(ISTEXT(A3),--RIGHT(A3,4),YEAR(A3))

This works on your sample but with other potential mixes, you might
have to amend. I've coerced the text return to a number for
consistency of return.
 
G

Guest

Hi

Try
=RIGHT(A1,2)
Note that if these are Excel dates (which some may be) you may need to use
=TEXT(A1,"yy")
which will return the year as text - ie 04 - or
=YEAR(A1)
which will return 2004
 
P

papou

Hi Viilis
How about a formula?
Assuming values entered in either real dates or text ending with year:
=IF(NOT(ISERROR(YEAR(A1))),YEAR(A1),VALUE(RIGHT(A1,4)))

HTH
Cordially
Pascal
 
Top