Excel Date Formula

I pull a year to date report for trouble tickets. What I wanted to do is if the date in cell A2 is between 2 certain dates suchs as Monday January 14th and Friday January 18th I want it to Dispaly January 18th (Fridays date) in Z2. The reason being is I want to pivot the week ending results. Unless someone has an easier way?
LVL 19
Edward PamiasTeam Lead RRS DeskAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Saqib Husain, SyedConnect With a Mentor EngineerCommented:
Try

=A2+7-WEEKDAY(A2,16)
0
 
giltjrConnect With a Mentor Commented:
Assuming the date you want is in Column A:

=SUM(A1+(7-(WEEKDAY(A1,16))))
0
 
gowflowCommented:
if you pull a weekly report then why not do
WEEKNUM("1/14/2013") will return 3 and
WEEKNUM("1/18/2013") will also return 3
then no matter what the date is will return same value if in same week.
gowflow
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Edward PamiasTeam Lead RRS DeskAuthor Commented:
My week is only 5 days. The techs do not work over the weekend.  =X2+(5-WEEKDAY(X2,2)) - <--- here is the formula that works for me. Thanks for the help guys!
0
 
Saqib Husain, SyedEngineerCommented:
Try

=A2+7-WEEKDAY(A2,16)
0
 
Edward PamiasTeam Lead RRS DeskAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for epamias's comment #a38798864

for the following reason:

Thanks all for the suggestions!
0
 
gowflowCommented:
did yyou try mine ??? Weeknum !!!
gowflow
0
 
giltjrCommented:
Did you come up with your formual before or after ssaqibh's post?

It is typically common courtesy to award some points to answers that helped you come to the your solution.  

Especially if they work, which ssaqibh's solution works independent of the number of days your staff works.  I know it works because if you look its the same as mine, and I tested my.

As for gowflow, unfortunately using the weeknum does not help if you need the date.  Unless you know something that you are not posting, you can't find the date of the last day of the week just knowing the week num, you would need to know some date during the week.  However if you notice the formula posted by ssaqubh (and myself)  do make use of weeknum.
0
 
Saqib Husain, SyedEngineerCommented:
In what way does your formula give different results from the proposed solution?
0
 
barry houdiniCommented:
Note that WEEKDAY with 16 as second argument is only available in Excel 2010 or later versions - you can get the same results with these versions

=A2+7-WEEKDAY(A2+1)

and

=A2+7-WEEKDAY(A2,16)

The former works in any version of excel

regards, barry
0
 
Edward PamiasTeam Lead RRS DeskAuthor Commented:
After the first 2 posts I did come up with formula. The first 2 did not work for me. So I went and searched for another solution while I was waiting. I modified what I found to work for me. You can close this question.
0
 
Saqib Husain, SyedEngineerCommented:
Which excel are you using?
0
 
Edward PamiasTeam Lead RRS DeskAuthor Commented:
I tried the other formulas as well they did not work even after modifications.
0
 
Edward PamiasTeam Lead RRS DeskAuthor Commented:
Excel 2010 - my formula worked fine.  =X2+(5-WEEKDAY(X2,2))  I answered my own question. Since it is a 5 day work week this works. Thanks.
0
 
Saqib Husain, SyedEngineerCommented:
Can you show us how the results of the first formula differ from yours?
0
 
giltjrCommented:
Um, I know I tested what I posted and it worked.  The only difference between mine and ssagibh's is I explicitly used the SUM function.  So I know his workes also.

In fact here are the results from all 3 formulas, hopefully it looks O.K. and makes sense.
 The only differnece game on the weekend.  Your's puts the date as the prior Fri., ours puts it as the following.

DOW        Actual Date      Yours      ssagibh's      Mine
MON      1/21/2013      1/25/2013      1/25/2013      1/25/2013
TUE      1/22/2013      1/25/2013      1/25/2013      1/25/2013
WED      1/23/2013      1/25/2013      1/25/2013      1/25/2013
THUR      1/24/2013      1/25/2013      1/25/2013      1/25/2013
FRI      1/25/2013      1/25/2013      1/25/2013      1/25/2013
SAT      1/26/2013      1/25/2013      2/1/2013      2/1/2013
SUN      1/27/2013      1/25/2013      2/1/2013      2/1/2013
MON      1/28/2013      2/1/2013      2/1/2013      2/1/2013
TUE      1/29/2013      2/1/2013      2/1/2013      2/1/2013
0
 
Edward PamiasTeam Lead RRS DeskAuthor Commented:
The formula I use  which works fine for me is in the attached sheet.. Keep in mind Friday of each week is the week ending date.   See attached sheet.
sampleBook1.xlsx
0
 
Edward PamiasTeam Lead RRS DeskAuthor Commented:
I just realized for desktop the beginning of my week is Monday and ends Friday. So the formula works fine but for Mobility this wont work since my week starts Saturday and ends Friday.
0
 
giltjrCommented:
However the formula first posted by ssaqibh will put the date for Sat. as the following Fri., which seem to be what your software product needs.
0
 
Rob HensonFinance AnalystCommented:
To throw another option into the fray:

=CEILING(X2,7)-1

This will round a date up to the following Friday. The CEILING function rounds up to factor specified, in this case 7 which ends up at the Saturday and then minus 1 to get Friday.

Likewise, FLOOR will round down.

This works because Day 1 in Excel history, back in January 1900, is a Sunday.

Thanks
Rob H
0
 
Edward PamiasTeam Lead RRS DeskAuthor Commented:
Thanks guys.... they first 2 did worked for me.
0
 
barry houdiniCommented:
>=CEILING(X2,7)-1

Hello Rob,

I always prefer to use WEEKDAY function because results will be consistent regardless of date system - if you are using 1904 date system then the above formula will give you a Thursday date rather than a Friday

regards, barry
0
All Courses

From novice to tech pro — start learning today.