+ Reply to Thread
Results 1 to 6 of 6

Formula to test if date is in the previous calendar month

Hybrid View

  1. #1
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Formula to test if date is in the previous calendar month

    Hi,

    I'm after a formula that will return true if a date is within the previous calendar month. I can test by comparing month(today()) and month(today())-1, but the problem comes when the new year ticks over. How can I handle the change of year?

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,064

    Re: Formula to test if date is in the previous calendar month

    With the date you are querying in A1, try this:

    =AND(A1<=EOMONTH(B1,-1),A1>EOMONTH(B1,-2))

    or this:

    =AND(A1<=EOMONTH(TODAY(),-1),A1>EOMONTH(TODAY(),-2))
    Last edited by AliGW; 12-02-2017 at 09:56 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

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

    Re: Formula to test if date is in the previous calendar month

    This would do it

    =EOMONTH(A1,0)=EOMONTH(TODAY(),-1)
    Audere est facere

  4. #4
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Formula to test if date is in the previous calendar month

    Quote Originally Posted by daddylonglegs View Post
    This would do it

    =EOMONTH(A1,0)=EOMONTH(TODAY(),-1)
    This is perfect!

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,064

    Re: Formula to test if date is in the previous calendar month

    Yes, it would - good one!

  6. #6
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012
    Cool. Thanks guys. I'll give it a try on Monday, it looks like that will do the trick.
    Last edited by AliGW; 12-02-2017 at 10:20 AM. Reason: Unnecessary quotation removed.

+ 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. [SOLVED] Formula to return End OF Month date with non-calendar month lengths.
    By Snoddas in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 05-09-2014, 08:45 AM
  2. [SOLVED] Formula issue for Current/Previous month Date
    By hecgroups in forum Excel General
    Replies: 3
    Last Post: 03-01-2014, 06:41 AM
  3. [SOLVED] Calendar Formula- Date given/add 90 days/ defult - 1st day next month
    By Gower Girl in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-24-2013, 06:21 PM
  4. Replies: 5
    Last Post: 10-04-2012, 07:06 AM
  5. [SOLVED] VBA to identify the current month and previous month based on system date
    By ravikumar00008 in forum Excel General
    Replies: 10
    Last Post: 07-26-2012, 10:04 AM
  6. Replies: 3
    Last Post: 01-09-2010, 08:42 AM
  7. is there a formula to generate a calendar month date rather than .
    By lmurray in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-21-2005, 12:06 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