Automatic date spans in Excel

I am in need of a formula that if the current date is between the 1st and 15th of the month the date span will be the 16th through the end of the previous month.  If the current date is between the 16th and the end of the month, then the date span will be the 1st to the 15th of the current month.

Thank you in advance for any help.
jmkbrownAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rspahitzCommented:
Can you explain what you mean by "date span"?  Normally cells only show individual values.  Are you looking for all dates in adjacent cells?
For example, if A1 = 2/1/2013, then A2=1/16, A3=1/17, A4=1/18, etc?
0
jmkbrownAuthor Commented:
Sorry for example
A1 = 09/19/2013 then
A2 = 09/01/2013
A3 = 09/15/2013
0
barry houdiniCommented:
How do you want to return the "date span"? As a text value you can try this

=IF(DAY(TODAY())<16,"16-"&TEXT(EOMONTH(TODAY(),-1),"d mmm yyyy"),"1-15 "&TEXT(EOMONTH(TODAY(),-1)+1,"mmm yyyy"))

Today that will give you this:

1 - 15 Sep 2013

but on 1st October you'll get

16 - 30 Sep 2013

regards, barry
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Rgonzo1971Commented:
Hi,

pls try =IF(DAY(E5)<=15,EOMONTH(E5,-2)+16,EOMONTH(E5,-1)+1)

and

=IF(DAY(E5)<=15,EOMONTH(E5,-1)-1,EOMONTH(E5,-1)+15)

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rspahitzCommented:
This formula can give you the 1st of the current month or 16th of the previous month for any given date:

=IF(DAY(A1)<16, DATE(YEAR(A1-15),MONTH(A1-15),16),DATE(YEAR(A1),MONTH(A1),1))
0
barry houdiniCommented:
Sorry, I thought you wanted text.....if you have today's date in A1 try this:

In A2.....

=IF(DAY(A1)>15,A1-DAY(A1)+1,EOMONTH(A1,-2)+16)

and this one in A3

=IF(DAY(A2)=1,A2+14,EOMONTH(A2,0))

regards, barry
0
Rob HensonFinance AnalystCommented:
Start date:

=IF(DAY(TODAY())<16,EOMONTH(TODAY(),-2)+16,EOMONTH(TODAY(),-1)+1)

Finish Date:

=IF(DAY(TODAY())<16,EOMONTH(TODAY(),-1),EOMONTH(TODAY(),-1)+15)

In xl03 EOMONTH needs AnalysisToolpak AddIn enabled.

Thanks
Rob H
0
jmkbrownAuthor Commented:
Thank you very much!  This worked perfectly!
0
barry houdiniCommented:
>=IF(DAY(E5)<=15,EOMONTH(E5,-1)-1,EOMONTH(E5,-1)+15)

If DAY(E5)<=15 that will give you the day before the end of the month, the -1 after the first EOMONTH isn't required, should be:

=IF(DAY(E5)<=15,EOMONTH(E5,-1),EOMONTH(E5,-1)+15)

regards, barry
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.