+ Reply to Thread
Results 1 to 4 of 4

Date function not accounting for leap year

  1. #1
    Registered User
    Join Date
    09-18-2013
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2010
    Posts
    2

    Date function not accounting for leap year

    I have a spreadsheet with this year's and previous year's data. I need to have the last day of the month pulled into a specific cell so the rest of my formulas work. Instead of inputting this years date and last years date, I would like to dumb it down so only one date needs to be changed. The formula I am using is =DATE(YEAR(B5),MONTH(B5)-12,DAY(B5)). B5 = Current Month End Date (i.e. 2/29/2012) The issue arises when the current year's date is a leap year (i.e 2/29/2012). This formula pulls in 3/1/2011. I need it to pull in 2/28/2011. I need this formula to work for both leap year and non leap year so the other users don't have to think too hard and do too much work. So if there is something that can be done where it will pull in the last date of the current month please let me know.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Date function not accounting for leap year

    use end of month
    =EOMONTH(A1,-12)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    09-18-2013
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Date function not accounting for leap year

    Perfect. Thank you

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Date function not accounting for leap year

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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. Having a problem with my If Leap Year Function
    By Cruse in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-28-2013, 04:12 PM
  2. Replies: 5
    Last Post: 10-26-2012, 05:43 AM
  3. Excluding the leap year in a date formula
    By babstierney in forum Excel General
    Replies: 4
    Last Post: 08-27-2012, 05:47 AM
  4. [SOLVED] Leap year date
    By P M Robbins in forum Excel General
    Replies: 5
    Last Post: 03-30-2006, 05:35 PM
  5. Leap year date problem
    By peter.thompson in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-09-2006, 07:31 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