Function to determine if AM or PM

G

gtslabs

I have some times that I need a separate cell to look at that time and
tell me if it is AM or PM. I tried using the Right(A1,2) but that did
not work even though I see the PM in the input bar. I also tried
if(A1>12:00,"PM","AM") but that did not work either. Any help would
be appreciated.
 
N

Niek Otten

=IF(A1>0.5,"PM","AM")

Works if there is only time in A1, not a date too. You can check by formatting A1 (temporarily) as general; it should be less than
1.

If there is a date part:

=IF(MOD(A1,1)>0.5,"PM","AM")

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


|I have some times that I need a separate cell to look at that time and
| tell me if it is AM or PM. I tried using the Right(A1,2) but that did
| not work even though I see the PM in the input bar. I also tried
| if(A1>12:00,"PM","AM") but that did not work either. Any help would
| be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top