+ Reply to Thread
Results 1 to 3 of 3

Date no more than 9 months ahead.

  1. #1
    Registered User
    Join Date
    01-17-2011
    Location
    Wiltshire, England
    MS-Off Ver
    Excel 2007
    Posts
    36

    Date no more than 9 months ahead.

    Hi All

    I hope someone can help me with this problem.

    i work for a food manufacturer and am writing a little Excel program to show the correct use by date to be printed on the cartons.
    B1=DATE(YEAR(A1),MONTH(A1)+9,DAY(A1)) by using this formula I get the correct answer ie; date in A1 17/01/2011 date in B1 17/10/2011.

    A problem arises when there are more days in the current month than the one 9 months ahead
    ie; A1 = 30/05/2011 B1 = 01/03/2012
    A1 = 30/05/2011 B1 = 02/03/2012

    The date needs to stay in the same month and not roll over to the next month.

    What I need is A1 = 30/05/2011 B1 = 29/02/2012
    A1 = 30/05/2011 B1 = 29/02/2012

    Hope you understand and can help

    Thanks in advance
    Last edited by processchip; 01-17-2011 at 06:50 AM.

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Date no more than 9 months ahead.

    try this

    =IF(DAY(DATE(YEAR(A1),MONTH(A1)+9,DAY(A1)))=DAY(A1),DATE(YEAR(A1),MONTH(A1)+9,DAY(A1)),DATE(YEAR(A1),MONTH(A1)+10,1)-1)

  3. #3
    Registered User
    Join Date
    01-17-2011
    Location
    Wiltshire, England
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Date no more than 9 months ahead.

    Thank you very much, it works brilliantly

+ 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