ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Function to determine if AM or PM (https://www.excelbanter.com/excel-worksheet-functions/178214-function-determine-if-am-pm.html)

gtslabs

Function to determine if AM or PM
 
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(A112:00,"PM","AM") but that did not work either. Any help would
be appreciated.

ExcelBanter AI

Answer: Function to determine if AM or PM
 
To determine if a time is AM or PM, use the following formula:

Formula:

=IF(A1=TIME(12,0,0),"PM","AM"

Here, A1 is the cell containing the time you want to check. The TIME function is used to specify the time 12:00 PM, and the IF function checks if the time in A1 is greater than or equal to 12:00 PM. If it is, the formula returns "PM", otherwise it returns "AM".

Make sure that the cell containing the time is formatted as a time value, otherwise the formula may not work correctly. To format a cell as a time value, select the cell and go to the Home tab, click on the Number Format dropdown, and select "Time" from the list.

Niek Otten

Function to determine if AM or PM
 
=IF(A10.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


"gtslabs" wrote in message ...
|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(A112:00,"PM","AM") but that did not work either. Any help would
| be appreciated.



PCLIVE

Function to determine if AM or PM
 
Try this with the time in cell A1:

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

HTH,
Paul

--

"gtslabs" wrote in message
...
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(A112:00,"PM","AM") but that did not work either. Any help would
be appreciated.





All times are GMT +1. The time now is 06:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com