+ Reply to Thread
Results 1 to 6 of 6

If statement using date format as logical_test

  1. #1
    Registered User
    Join Date
    05-30-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    2

    If statement using date format as logical_test

    Hi there,

    I'm trying to do the following in excel, yet to no avail:

    1) I have a date cell for B2, B3 etc etc eg. 29-Jan-10

    2) What I want to do is: If month = Jan, enter Jan into C2, if month = Feb, enter Feb into C2, and so forth

    3) This is what I've tried to test for Jan (I'll add the rest of the months in once I get Jan working)

    =IF(B2="29/1/2010","Jan","Blah")
    =IF(B2="*/1/*","Jan","Blah")
    =IF(B2="*-1-*","Jan","Blah")
    =IF(B2="*-Jan-*","Jan","Blah")

    And the output is Blah every time...

    Not sure if my logic is wrong here, or whether I've made a minor mistake, but I can't seem to get this to work.

    Any help is greatly appreciated

    Regards,
    David

  2. #2
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Rowley
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: If statement using date format as logical_test

    Try this:

    =IF(MONTH(B2)=1,"Jan","Blah")

  3. #3
    Forum Contributor
    Join Date
    12-03-2009
    Location
    Providence RI
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    260

    Re: If statement using date format as logical_test

    Wait so you just want the month placed in C? Thats how you explain it....I think. Why not just do this....

    =TEXT(MONTH(B2),"MMM")

  4. #4
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Rowley
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: If statement using date format as logical_test

    You can also just place the =MONTH() function in C2 as:

    =MONTH(B2)

    Normally, the result will be a number, but you can format the cell to show the actual
    month by using Format,Cells,Number,Custom and using the code mmm or mmmm.

  5. #5
    Forum Contributor
    Join Date
    12-03-2009
    Location
    Providence RI
    MS-Off Ver
    Excel 2007, Excel 2010
    Posts
    260

    Re: If statement using date format as logical_test

    Or wrap with TEXT

  6. #6
    Registered User
    Join Date
    05-30-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: If statement using date format as logical_test

    Thanks for your help guys!

+ 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