+ Reply to Thread
Results 1 to 11 of 11

Using dates in an IF statement

  1. #1
    Registered User
    Join Date
    02-23-2011
    Location
    Hampshire, England
    MS-Off Ver
    Excel 2007
    Posts
    71

    Using dates in an IF statement

    Hello,

    I have tried using

    =IF(B2>DATE(2017,10,16),2,1)

    to classify records into two groups but it doesn't work.

    What should I be doing?

    Thanks

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,403

    Re: Using dates in an IF statement

    Too little information. In what way doesn’t it work? What exactly is in B2 and is it properly formatted?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,006

    Re: Using dates in an IF statement

    What is in B2? Formula is OK.

  4. #4
    Registered User
    Join Date
    02-23-2011
    Location
    Hampshire, England
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: Using dates in an IF statement

    B2 contains dates and I am getting a list of 1's.

    If the date is 17/10/16 or after I would like 2's and 1's prior to this date.

    Thanks.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,403

    Re: Using dates in an IF statement

    It's not a true date, then - probably text that looks like a date.

  6. #6
    Registered User
    Join Date
    02-23-2011
    Location
    Hampshire, England
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: Using dates in an IF statement

    Quote Originally Posted by AliGW View Post
    It's not a true date, then - probably text that looks like a date.
    I know they are numbers because I am getting the average and sum for the dates otherwise I would just be getting counts.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,403

    Re: Using dates in an IF statement

    Attach the workbook.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  8. #8
    Registered User
    Join Date
    02-23-2011
    Location
    Hampshire, England
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: Using dates in an IF statement

    Spreadsheet attached
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,198

    Re: Using dates in an IF statement

    DATE(2017,10,16) is the 16th of October 2017

    17/10/16 is 17th October 2016, what date do you want to use

    and think about if you need >= instead of >

    no date in you example is > 16th October 2017 hence you get 1 every time

  10. #10
    Registered User
    Join Date
    02-23-2011
    Location
    Hampshire, England
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: Using dates in an IF statement

    Thanks, I hadn't realized!

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,006

    Re: Using dates in an IF statement

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. [SOLVED] IF OR Statement with Dates
    By Webbers in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-24-2015, 09:18 AM
  2. If statement using dates.
    By CL-West in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-16-2014, 06:20 AM
  3. If Statement and dates
    By Cageyj0nny in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-11-2014, 08:03 AM
  4. If statement between dates
    By Burt_100 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-08-2014, 12:08 PM
  5. If statement with Dates
    By ktkreeger in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-02-2013, 04:26 PM
  6. If statement using Dates?
    By Brampy in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 07-11-2012, 05:04 PM
  7. [SOLVED] If Statement and Dates
    By Toys in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-21-2005, 08:35 AM

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