+ Reply to Thread
Results 1 to 5 of 5

display the current YEAR or next YEAR using an IF & AND function for MONTH and DAY

  1. #1
    Registered User
    Join Date
    10-07-2018
    Location
    Athens, Greece
    MS-Off Ver
    Microsoft Office 2016
    Posts
    3

    display the current YEAR or next YEAR using an IF & AND function for MONTH and DAY

    Hello,

    I'm hoping someone can help me with this. I'm trying to display either the current YEAR or next YEAR, ie 2018 or 2019, using an IF function for whether or not the MONTH and DAY entered in the the cell A2 matches today's date.
    What I'd like to do is have the cell show the current YEAR if the MONTH and DAY are >= to the current day then show the current year, if not, show the next year.

    I'm creating a simple spreadsheet of the domain names I have and I'd like to have it dynamically update to display when the year they expire.

    I have A2 with the date the domains were registered on and displayed as 15-Jan.

    In A3 I had entered the function
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and that will show the proper year but it doesn't take in to account the day so no matter what it will display the current year instead of the next year if warranted.

    I have also tried entering
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    but that only shows the formula in the cell and doesn't render the date.

    In this forum I have also found this formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    which returns a TRUE or FALSE result but I'm having trouble turning that in to an IF & AND function.

    Any help you can give me would be greatly appreciated!

    kind regards,

    Michael

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: display the current YEAR or next YEAR using an IF & AND function for MONTH and DAY

    Quote Originally Posted by mdkoontz View Post
    I have also tried entering
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    but that only shows the formula in the cell and doesn't render the date.
    If it shows the formula in the cell, then you have the cell formatted as Text. Change the formatting to General, double click on the cell, then hit ENTER and you should see the correct result.

    By the way, your logic is faulty. If the expiration date is Nov 15 2019 and you run this on today's date, then your formula will show 2018.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    10-07-2018
    Location
    Athens, Greece
    MS-Off Ver
    Microsoft Office 2016
    Posts
    3

    Re: display the current YEAR or next YEAR using an IF & AND function for MONTH and DAY

    Quote Originally Posted by 6StringJazzer View Post
    By the way, your logic is faulty. If the expiration date is Nov 15 2019 and you run this on today's date, then your formula will show 2018.
    Thank you for your help. Yes, you were correct, it was set to text. I hadn't realized I needed to change it to General.

    About my logic, I can see where you would get that, however the current date entered in to A1 does have the year but I'm only showing the current month and day and only referencing the current month and day in the formula. The true and false sections of the if statement are suppose to draw off of the current year from the PC and display the current year or the next year based off of the >= logic for the current month and day. Does that make more sense?

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: display the current YEAR or next YEAR using an IF & AND function for MONTH and DAY

    When a field is set to Text, it interprets anything you type into that field as a text string, even if it is a number or a formula. It should be used sparingly, only when necessary to get something to work. It is not necessary to format cells as Text just because you intend to use them for text; any format, such as General, will allow text in the cell.

    If your logic works for you then I'm not going to worry about it but I still don't understand how you can disregard the year from A1 in that comparison.

  5. #5
    Registered User
    Join Date
    10-07-2018
    Location
    Athens, Greece
    MS-Off Ver
    Microsoft Office 2016
    Posts
    3

    Re: display the current YEAR or next YEAR using an IF & AND function for MONTH and DAY

    Quote Originally Posted by 6StringJazzer View Post
    If your logic works for you then I'm not going to worry about it but I still don't understand how you can disregard the year from A1 in that comparison.
    Thanks again for the lesson on when and why to use text formatting in the cells.

    The reason I'm disregarding the year is because I don't want it there in there in the first place. I only care about the month and day. However, I'm unable to figure out how to have Excel only record a month and day without storing the year. For example, if I enter today's date as 10-07 then excel automatically adds the year if I have the cell formatted as a date. This is why I have chosen to show the date to be displayed, using today's date as an example, as 07-Oct. This then allows me to use the formula I want to target the month and day.

    The reason I don't care for the year in A1 is because I'm just tracking the month and day that a domain expires and I want A2 to dynamically change the year based on the current year so I don't have to go back and modify the entries after the domains renew. It's assumed the domains are still active if they are in the list.

    I hope with this explanation it makes more sense. If you know of a better way to accomplish what I'm after I'd love to hear it. Seriously, I'm open to suggestions because anything I can do to make things easier is great plus I'm always open to learning new ways to do things.

    kind regards,

    Michael

+ 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] How to get month and year of previous and current financial year?
    By mso3 in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 04-11-2017, 05:19 AM
  2. [SOLVED] Current year and month and Previous and year
    By Anjukeerthi in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-24-2014, 01:23 AM
  3. [SOLVED] Current day to display as Year, Month, Day?
    By OpOrange in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-21-2014, 09:41 PM
  4. Change year but keep the month the same based on current year
    By Jamon Fries in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-11-2014, 05:29 PM
  5. Replies: 3
    Last Post: 09-04-2013, 10:49 AM
  6. [SOLVED] Function to Output Current Month and Year
    By cg0789 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-13-2012, 01:46 PM
  7. Current Year & Month Name, Previous Year & Month Name
    By mithesh in forum Excel General
    Replies: 9
    Last Post: 10-21-2011, 07:00 AM

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