+ Reply to Thread
Results 1 to 5 of 5

Urgent help required with Month and Year functions

  1. #1
    Registered User
    Join Date
    03-30-2016
    Location
    Larne, N. Ireland
    MS-Off Ver
    2010
    Posts
    3

    Exclamation Urgent help required with Month and Year functions

    Hi All,
    I have entered the formula:


    =IF(B2>$L$1,"After Period End",(IF(MONTH($L$1)&YEAR($L$1)=MONTH(B2)&YEAR(B2),"0-30 days",(IF(MONTH($L$1)&YEAR($L$1)=MONTH(B2)+1&YEAR(B2),"31-60 days",(IF(MONTH($L$1)&YEAR($L$1)=MONTH(B2)+1&YEAR(B2)+1,"31-60 days",(IF(MONTH($L$1)&YEAR($L$1)=MONTH(B2)+2&YEAR(B2),"61-90 days", (IF(MONTH($L$1)&YEAR($L$1)=MONTH(B2)+2&YEAR(B2)+1,"61-90 days",(IF(MONTH($L$1)&YEAR($L$1)=MONTH(B2)+3&YEAR(B2),"91-120 days",(IF(MONTH($L$1)&YEAR($L$1)=MONTH(B2)+3&YEAR(B2)+1,"91-120 days","120+ days")))))))))))))))


    In cell B2 I have the date (British format) 05/12/2016
    In cell L1 I have the date (British format) 24/02/2017

    I am expecting my formula to produce the result 61-90 days but instead it produces 120+ days . What am I doing wrong? Can anyone help me?

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: Urgent help required with Month and Year functions

    Try this ...

    =IF(B2>$L$1,"After Period End",LOOKUP($L$1-B2,{0,31,61,91,121},{"0-30 days","31-60 days","61-90 days","91-120 days","120+ days"}))

  3. #3
    Registered User
    Join Date
    03-30-2016
    Location
    Larne, N. Ireland
    MS-Off Ver
    2010
    Posts
    3

    Re: Urgent help required with Month and Year functions

    Thanks Phuocam. You're kind of a genius but it doesn't meet the requirement I've been set, which was (Assuming the date in L1 is 24.02.2017), all dates that are XX/02/2017 should be labelled 0-30 days. All dates that are XX/01/2017 i.e. previous month should be 31-60 days. All dates that are XX/12/2017 should be 61-90 days etc.

    I know that seems counter intuitive, but it is for the purposes of monitoring movements of stock month on month so it is actually the most practical thing to do, given that the period end date (L1) is a different date each month (4-4-5 week periods).

    Anyway B2 = 24/01/2017 for example should produce 0-30 days, rather than 31-60 days, which your formula produces. Hence my brutal use of the month and year functions. Can you help me? I'm such a rookie.

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: Urgent help required with Month and Year functions

    =IF(B2>$L$1,"After Period End",LOOKUP(DATEDIF(EOMONTH(B2,0)+1,EOMONTH($L$1,0)+1,"m"),
    {0,1,2,3,4},{"0-30 days","31-60 days","61-90 days","91-120 days","120+ days"}))

  5. #5
    Registered User
    Join Date
    03-30-2016
    Location
    Larne, N. Ireland
    MS-Off Ver
    2010
    Posts
    3

    Re: Urgent help required with Month and Year functions

    Added to your reputation Phuocam. I'm slightly in love with your excel skills. Thank you.

+ 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. Running Totals from 24 hours to month, month to year without year decreasing
    By Safetyintern in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-20-2015, 01:13 PM
  2. [SOLVED] Date functions YEAR, MONTH, EOMONTH do not work for the array format?
    By alice2011 in forum Excel General
    Replies: 2
    Last Post: 05-06-2015, 08:59 PM
  3. Replies: 1
    Last Post: 03-24-2015, 01:42 PM
  4. Replies: 1
    Last Post: 06-05-2014, 09:48 AM
  5. Replies: 3
    Last Post: 09-04-2013, 10:49 AM
  6. If Column A Month and Year = ColumnB Todays Month and Year then send email
    By HACCStaff in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-15-2013, 12:47 AM
  7. Year, Month, Day, Weeknum functions in a macro
    By gathrawnca in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-05-2010, 10:28 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