+ Reply to Thread
Results 1 to 3 of 3

Problem with DATE function

  1. #1
    Registered User
    Join Date
    03-30-2014
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2013
    Posts
    2

    Problem with DATE function

    Hello,
    I’m having the following problem with the DATE function in excel. As you probably know when you add one month to a certain date using the formula: DATE(YEAR(A1);MONTH(A1)+1;DAY(A1)) you get one month shift from the date in cell A1 i.e the results is the exact same date, one month after. But when the date in A1 is end of the month and the following month is shorter than the initial one – there is a problem for me as excel results not at the end of the next month but at the beginning of the month after next. Example:
    A2= DATE(YEAR(A1);MONTH(A1)+1;DAY(A1))
    When A1=31.01.2015 the result in A2 is 03.03.2015
    When A1=03.02.2015 the result in A2 again is 03.03.2015 i.e. there is “time gap” of three days

    Obviously for such cases when the following month is shorter excel follows the logic: match the exact date until fulfilling the available dates, after that add 31 days no matter you end up in the month after next or not.
    In my case though this logic ruins the model I’m building as I need to keep within the month. When the formula results into the month after next that triggers some unwanted formulas and results.
    Can you suggest elegant way to stay within the month, no matter if it is shorter or longer than the previous one?

    Regards!

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,717

    Re: Problem with DATE function

    Try using EDATE to add months, i.e.

    =EDATE(A1,1)

    It won't go beyond the end of the month, so

    =EDATE(DATE(2014,1,31),1)

    gives you 28th February
    Audere est facere

  3. #3
    Registered User
    Join Date
    03-30-2014
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Problem with DATE function

    Works perfect!
    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. IF and Date Function problem
    By excelhelpme in forum Excel General
    Replies: 2
    Last Post: 01-31-2009, 10:34 AM
  2. Date Function Problem
    By subharr in forum Excel General
    Replies: 3
    Last Post: 08-01-2008, 06:42 AM
  3. If And Date Function Problem
    By andyp161 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-21-2007, 06:56 AM
  4. If Function - Date Problem
    By JEM in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-12-2006, 08:49 AM
  5. Date Function problem
    By VW_Dick in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-01-2005, 09:49 AM

Tags for this Thread

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