I am trying to write an IF statment that will recognize a single alpha character and return the first 5 characters. Here are the two types of data in the file:

JM7185
JM7186
JM7189P
JM7190P


Here is my formula:

=IF(E28<>"P",RIGHT(E28,5),RIGHT(E28,4))

I want the formula to look at the cell and recognize the "P" at the end. If it sees a P, then return the first 5 characters to the right and the first 4 if it doesn't see the P.

Any help on this would be greatly appreciated.

Juanita