+ Reply to Thread
Results 1 to 6 of 6

formula to calculate "previous month"

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    formula to calculate "previous month"

    I have an input cell in which i enter the current month and would like a formula to calculate the previous month based on my current month input cell.

    I've tried the "=current month input cell - 1" but this doesn't work :P

    The TODAY & NOW functions are no good here i would think as the current date differs from the actual date often by a couple of months.
    Last edited by Gti182; 11-15-2010 at 05:21 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: formula to calculate "previous month"

    If you want 1st of Prior Month

    =DATE(YEAR(A1),MONTH(A1)-1,1)
    If you want last day of Prior Month

    =DATE(YEAR(A1),MONTH(A1),0)
    If you want same day in Prior Month

    =DATE(YEAR(A1),MONTH(A1)-1,DAY(A1))
    but note the last of the above is open to error (eg 31st May would generate 1st May rather than 30th April)

    You might also consider use of EDATE - prior to XL2007 this warrants activation of the Analysis ToolPak Add-In on each client using the formula (see: Tools -> AddIns)

  3. #3
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Re: formula to calculate "previous month"

    I'm just after the month and year really so first formula works perfect for me! Thanks DonkeyOte

  4. #4
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Re: formula to calculate "previous month"

    Dope i see now the "=current month input cell - 1" actually does work but my formatting was mmm-mm istead of mmm-yy. Rookie mistake

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: formula to calculate "previous month"

    That holds true only if the current cell is 1st of month.

    In essence Date values in XL are Serial Numbers where 24 hours equates to 1

    It follows that if you subtract 1 from an existing date you are subtracting 1 day.
    So where current date is 1st of month you end up with last day of prior month which - pending latter calcs - may / may not be an issue.

    Using the DATE construct whereby Month is adjusted is slightly more robust though again not infallible - all depends on context
    (in this instance I'd say you are better off using the DATE based approach)

  6. #6
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    Re: formula to calculate "previous month"

    thanks for that mate, i've opted for your date forumula as its a bit more impressive than mine the 24 hour thing is really useful info to know. cheers

+ 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