+ Reply to Thread
Results 1 to 15 of 15

Need help with date calculations

  1. #1
    Forum Contributor
    Join Date
    07-06-2021
    Location
    USA
    MS-Off Ver
    365
    Posts
    253

    Need help with date calculations

    If that date is 1 month behind today's date, the output needs to be - "1 Month Behind"
    If the date is 2 months behind today's date, the output needs to be - "2 Months Behind"
    If the date is 3 (or more) months behind today's date, the output needs to be - "3 Months or More Behind"
    If the date is blank, then the output needs to be - "Blank"
    If the date is after today's, or future, date then the output needs to be - "Up-To-Date"

    I have a semi functional formula working which is attached in the spreadsheet. The problem is that in A8, I have a highlighted date. Technically, the formula is correct, but that's not what I needed. 5 is two less than 7 so the output should be "2 Months Behind".

    Thanks in advance.
    Attached Files Attached Files

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

    Re: Need help with date calculations

    Administrative Note:

    Although we value your privacy as much you do, it could be important that members have a rough idea of your location as the solutions they offer may be affected by your locale. For instance, you might in the future post questions which are related to your regional settings.

    With this in mind, please update your profile to something more precise (something such as UK, Europe, USA, UAE, etc. will suffice).

    Thank you for helping us to help you.
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,987

    Re: Need help with date calculations

    Does this do what you want?

    =IF(A2="","Blank",IF(DATEDIF(A2,TODAY(),"m")=0,"Up-To-Date",LOOKUP(DATEDIF(A2,TODAY(),"m"),{1,2,3},{"1 Month Behind","2 Months Behind","3 Months or More Behind"})))

  4. #4
    Forum Contributor
    Join Date
    07-06-2021
    Location
    USA
    MS-Off Ver
    365
    Posts
    253

    Re: Need help with date calculations

    Thank you, I changed mt location.

    And no it doesn't work, unfortunately. The output for date 7/12/23 says that it's "3 or More Months Behind", which the output should say, "Up-To-Date".

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

    Re: Need help with date calculations

    It says Up-to-Date here! I'm in the UK, so dates show as dd/mm/yyyy.

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    A
    B
    1
    Last Note
    2
    12/07/2023
    Up-To-Date
    3
    20/07/2023
    Up-To-Date
    4
    21/06/2023
    1 Month Behind
    5
    04/04/2023
    3 Months or More Behind
    Sheet: Sheet1
    Attached Files Attached Files
    Last edited by AliGW; 07-25-2023 at 10:45 AM.

  6. #6
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,005

    Re: Need help with date calculations

    Try this in B2

    Please Login or Register  to view this content.
    copied down.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    07-06-2021
    Location
    USA
    MS-Off Ver
    365
    Posts
    253

    Re: Need help with date calculations

    I see what I did wrong with my copy and paste. It's working now, but unfortunately it's not quite working out for the cell in question still.
    Attachment 837625

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,987

    Re: Need help with date calculations

    It is working: 31 May will NOT be two months behind until 31 July, and it's 25 July today.

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  9. #9
    Forum Contributor
    Join Date
    07-06-2021
    Location
    USA
    MS-Off Ver
    365
    Posts
    253

    Re: Need help with date calculations

    That's almost it! The problem is now when it's a future date sometime in 2026 (manually changed it for the sake of testing it) it's return is "#N/A".

  10. #10
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Need help with date calculations

    Please try in B2 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,987

    Re: Need help with date calculations

    You could use this if you wanted 31 May to be 2 months behind:

    =LET(t,EOMONTH(TODAY(),0)+1,IF(A2="","Blank",IF(DATEDIF(A2,t,"m")=0,"Up-To-Date",LOOKUP(DATEDIF(A2,t,"m"),{1,2,3},{"1 Month Behind","2 Months Behind","3 Months or More Behind"}))))

    As for testing, you would need to change each instance of TODAY() with something like DATE(2026,1,1) where the arguments are DATE(year,month,day).

  12. #12
    Forum Contributor
    Join Date
    07-06-2021
    Location
    USA
    MS-Off Ver
    365
    Posts
    253

    Re: Need help with date calculations

    This works!

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,987

    Re: Need help with date calculations

    What works? Mine or Hans'? They both do, probably.

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  14. #14
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Need help with date calculations

    Thanks for the rep .

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,987

    Re: Need help with date calculations

    Lucky you - I didn't get any.

+ 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. Help with Date Calculations
    By windpowerfinance in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 04-02-2017, 07:31 AM
  2. Date calculations - adding number of days to a date
    By Dave Goldman in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 03-12-2011, 12:44 PM
  3. date calculations
    By catwood in forum Excel General
    Replies: 7
    Last Post: 11-11-2008, 04:10 PM
  4. Date and time calculations and automatic date changes
    By Arlette in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-09-2006, 05:25 AM
  5. date calculations
    By kraway in forum Excel General
    Replies: 1
    Last Post: 01-11-2006, 10:00 AM
  6. Date Calculations
    By mulhod in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  7. Date Calculations
    By mulhod in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 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