Solved

Date help, within 60 days of Dec or June

Posted on 2014-09-24
5
120 Views
Last Modified: 2014-09-25
How would I modify the following for 60 days before December 31 and June 30.  So, bassed on today, the return would be 60 days before Dec 31 and when that day is passed then 60 days before June 30.

not sure if there is more simple formula out there.  Maybe using EOMonth possibly.   I dont understand the below formula.
DATE(YEAR(NOW()),CHOOSE(MONTH(NOW()),IF(DAY(NOW())>15,6,0),6,6,6,6,6,IF(DAY(NOW())>15,12,6),12,12,12,12,12),0)

thank you
0
Comment
Question by:pdvsa
  • 3
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 total points
Comment Utility
The above formula returns 11/30/2014 in relation to today's date (9/24/2014).  I presume you expect 11/1/2014 instead (60 days before 12/31/2014).

So if
1/1 through 5/1 ===> 5/1 (60 days before June 30, current year)
5/2 through 11/1 ===> 11/1 (60 days before Dec 31, current year)
11/2 through 12/31 ===> 5/1 (60 days before June 30, next year)

If this assumption is correct then this formula will produce the result:
=IF(NOW()<=DATE(YEAR(NOW()),5,1),DATE(YEAR(NOW()),5,1),IF(NOW()<=DATE(YEAR(NOW()),11,1),DATE(YEAR(NOW()),11,1),DATE(YEAR(NOW())+1,5,1)))

Regards,
-Glenn
0
 

Author Closing Comment

by:pdvsa
Comment Utility
very nice!  You are obviously very good at this.
0
 

Author Comment

by:pdvsa
Comment Utility
hope you are still monitoring.  I actually had it made a mistake.  I said before 60 days but it should be after 60 days from June 30 / Dec 31.  I dont see how to modify that.  Its too complicated.  Can you make that edit?  thank you
0
 
LVL 27

Expert Comment

by:Glenn Ray
Comment Utility
Pretty big mistake! :-)

If I replace "before" with "after" in your original statement:
How would I modify the following for 60 days after December 31 and June 30.  So, based on today, the return would be 60 days after Dec 31 and when that day is passed then 60 days after June 30.

So if:
1/1 through 2/29 or 3/1 ===> 2/29 or 3/1 (60 days after Dec 31, in current year, depends on if a leap year)
3/1 or 3/2 through 8/29 ===> 8/29 (60 days after June 30, current year, depending on if a leap year)
8/30 through 12/31 ====> 2/29 or 3/1 (60 days after Dec 31, next year)

 If this assumption is correct then this formula will produce the result:
=IF(NOW()<=DATE(YEAR(NOW()),2,29),DATE(YEAR(NOW()),2,29),IF(NOW()>=DATE(YEAR(NOW()),8,30),DATE(YEAR(NOW()),12,31)+60,DATE(YEAR(NOW()),8,29)))

Note that the first DATE function - DATE(YEAR(NOW()),2,29) - is tricking Excel to show either 2/29 or 3/1, depending on if it is a leap year.

Any other changes...you gotta ask a new question! :-D

-Glenn
0
 

Author Comment

by:pdvsa
Comment Utility
you are really really good at this.  I hope you make a lot of money doing this.  

thank you.  

will probably post another similar question in a bit.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now