+ Reply to Thread
Results 1 to 6 of 6

Using Dates in IF statements

  1. #1
    Registered User
    Join Date
    05-08-2013
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Using Dates in IF statements

    I am trying to categorize data within 2 dates.

    For example, if date is on or before 7/18/13, I want to categorize it as "Past Due".

    I've tried the following formulas but it's not calculating all my data correctly:

    =If(X2>7/18/2013,"Past Due","Other")

    =IF(X2>"7/18/2013","Past Due","Other")

    I've even tried TEXT(X2,"MMDDYYYY") for the X2 value.

    What am I doing wrong?

    It's categorizing dates after 7/18 as "Past Due" and vice versa.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,426

    Re: Using Dates in IF statements

    Try it like this:

    =If(X2<=--"7/18/2013","Past Due","Other")

    The double-minus converts the text string into a date for the comparison, but it would be more robust if you did this:

    =If(X2<=DATE(2013,7,18),"Past Due","Other")

    Hope this helps.

    Pete

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Using Dates in IF statements

    Either use a cell to hold the date and refer to that cell (best option), or use the DATE( ) function.

    A1 = 7/18/2013

    =IF(X2>A1,"Past Due","Other")


    =IF(X2>DATE(2013,7,18),"Past Due","Other")
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    05-08-2013
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Using Dates in IF statements

    I tried using a cell to hold the date but it didn't work.

    Thank you, I think I have it working now

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Using Dates in IF statements

    Quote Originally Posted by jbutzer72 View Post
    I tried using a cell to hold the date but it didn't work.
    What about it didn't work?

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,426

    Re: Using Dates in IF statements

    Your comparisons are the wrong way round if you want dates before X2 to return "Past Due" - i.e. the date is less than X2's date.

    Hope this helps.

    Pete

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. IF statements and due dates
    By jh-biscoe in forum Excel General
    Replies: 4
    Last Post: 11-21-2011, 11:08 AM
  2. If Statements with Dates
    By jmarshall in forum Excel General
    Replies: 9
    Last Post: 11-24-2008, 02:08 PM
  3. IF statements using DATES
    By tttt in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-13-2007, 12:51 AM
  4. Help with Dates and IF Statements
    By chrysti in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-19-2006, 04:57 PM
  5. [SOLVED] if statements & dates?
    By Lynn in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-19-2005, 12:05 PM

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