+ Reply to Thread
Results 1 to 3 of 3

Calculate Time on AM/PM basis

  1. #1
    Forum Contributor
    Join Date
    08-12-2010
    Location
    Excel World
    MS-Off Ver
    Excel 2013, 2019 & O365
    Posts
    214

    Calculate Time on AM/PM basis

    Hi All,

    I have a column with some values of times, like below format:
    Cell B1 = 3/8/2013 13:00
    Cell B2 = 3/22/2013 0:25
    Cell B3 = 2/28/2013 13:52

    I have to calcuate Time on AM/PM basis as per below instruction:
    = If(Cell B1< "01:00:00 PM", 8, 0)

    I simply tried to apply this formula to convert the time into text >---> =TEXT(Cell B1,"hh:mm:ss am/pm")
    So now it gives me result as GivenTime = 3/8/2013 1:00:06 PM
    = If(GivenTime < "01:00:00 PM", 8, 0)

    ... but it is not giving me the correct result, Can anyone please help me to figure it out.
    Thanks in advance!
    Last edited by SunOffice; 05-02-2013 at 11:10 PM. Reason: Explained more...
    Excelforum is Completely Awesome! True learning with Live Examples & Best Techniques!!

  2. #2
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Calculate Time on AM/PM basis

    I made a fool of myself with Text before on this forum. You have to do tests like yours on the binary format, not a text one.

    So although you can set the format of the cells as you show, you can't use text. Just set as a custom format. Then your formula becomes =hour(A1)<13 which returns True or False. or to get your result
    Please Login or Register  to view this content.
    Last edited by brynbaker; 04-30-2013 at 05:46 AM. Reason: more complete answer, obey forum rule

  3. #3
    Forum Contributor
    Join Date
    08-12-2010
    Location
    Excel World
    MS-Off Ver
    Excel 2013, 2019 & O365
    Posts
    214

    Re: Calculate Time on AM/PM basis

    Thank you so much brynbaker!

    Yeah! It's working fine. And your the format change option is also a good trick.
    Last edited by SunOffice; 05-02-2013 at 11:12 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1