Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Date help, within 60 days of Dec or June

Posted on 2014-09-24
5
Medium Priority
?
133 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 2000 total points
ID: 40342448
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
ID: 40342622
very nice!  You are obviously very good at this.
0
 

Author Comment

by:pdvsa
ID: 40342662
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
ID: 40343232
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
ID: 40343921
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

916 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