+ Reply to Thread
Results 1 to 11 of 11

If statement with time format

  1. #1
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    If statement with time format

    I am trying to do a simple IF statement of something in a time format. For example, =IF(A1=TIME(8,30,0),1,2). I have my cell A1 formatted to 24 hour time (i.e. 08:30), but I can never return a true result. Any thoughts?
    Last edited by bigmantitus; 06-24-2013 at 02:28 PM.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: If statement with time format

    Your formula works for me..
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Is A1 a real time value, without a date part?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: If statement with time format

    Quote Originally Posted by Norie View Post
    Is A1 a real time value, without a date part?
    Yeah, that seems to be the issue. It works fine if the value is just a time value, but once it is a time + date, it fails. My cell will unfortunately be both a date and time. Any way to get around it?

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: If statement with time format

    You can extract the time part from A1 and use that in the formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: If statement with time format

    Quote Originally Posted by Norie View Post
    You can extract the time part from A1 and use that in the formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks for the response but that doesn't seem to work for me. MOD does pull out the time, but using an IF statement with TIME still doesn't return a true result.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: If statement with time format

    Can you upload an example workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  8. #8
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,298

    Re: If statement with time format

    Please Login or Register  to view this content.
    This formula gives a 1 if it is true and a 2 if it is false
    If you want 'TRUE' or 'FALSE' as a result use this formula
    Please Login or Register  to view this content.
    Last edited by popipipo; 06-24-2013 at 12:36 PM.
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  9. #9
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: If statement with time format

    I have attached the simple workbook. What it eventually displays (either a number or true/false) doesn't matter since I can always customize the true and false results of the IF statement. What I cannot get it to do is ever yield a true result using the TIME function (which is the only way I can think of to try this).
    Attached Files Attached Files

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: If statement with time format

    It's a rounding/floating point problem.

    Try this instead, though I'm sure there's a better way.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: If statement with time format

    That worked! Thanks much.

+ 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