+ Reply to Thread
Results 1 to 3 of 3

Formula for Time

Hybrid View

  1. #1
    Registered User
    Join Date
    07-28-2009
    Location
    Chicago, Il
    MS-Off Ver
    Excel 2007
    Posts
    67

    Formula for Time

    I am trying to get a formula that will state specific data if within a time frame

    I have cell A20 as =NOW()

    Then have A21 as =IF(A20<TIME(13,50,0),"10:00 AM",IF(AND(A20>TIME(13,51,0),A20<TIME(17,50,0)),"2:00 PM",IF(AND(A20>TIME(17,51,0),A20<TIME(21,50,0)),"6:00 PM","10:00 PM")))

    for some reason this will not work can someone tell me what i am doing wrong or point me in the right direction


    Thanks

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,699

    Re: Formula for Time

    Hello Ricardo,

    =NOW() contains the date as well as time and therefore will always be greater than all of your times, hence the default value of 10:00 PM is always returned.

    Try making A20 just the current time, i.e.

    =MOD(NOW(),1)

    then your formula will work in most cases....although I note that if the current time is 13:50 it will also return 10:00 PM because you haven't closed off all the time ranges.....you could try this version with LOOKUP

    =LOOKUP(A20,{0,"13:50","17:50","21:50"}+0,{"10:00 AM","2:00 PM","6:00 PM","10:00 PM"})

  3. #3
    Registered User
    Join Date
    07-28-2009
    Location
    Chicago, Il
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Formula for Time

    That worked pefectly both ways i ended up closing the AM time with 12:01am so both worked but i definately liked yours better


    Thanks alot

    now the powers that be have me on bigger badder things
    Last edited by Ricardo9211; 11-12-2009 at 06:58 PM. Reason: Resolved

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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