In Google Sheets, I have 3 columns.

  1. Column A contains one of two text strings: 12-Hour or 24-Hour.
  2. Column B contains a time that may be in a 12-hour or 24-hour format. eg. 2:00 PM , 14:00 , etc.
  3. In Column C I would like a formula that will return the time from column B with the format based on the selection in column A.

Sample Data

1 Selection Time Result
2 12-Hour 2:00 PM 2:00 PM
3 24-Hour 2:00 PM 14:00
4 12-Hour 14:00 2:00 PM
5 24-Hour 14:00 14:00

What is an efficient way to achieve this?


1 Answer 1


Use text(), like this:

=text(B2, if(A2 = "12-Hour", "h:mm am/pm", "h:mm"))

See text().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.