I have an issue here. I want to calculate the week nummber of first sunday of business year. Where I work their calendar starts on February 1st. To calculate i have a column A2 in excel which has the date in mm/dd/yyyy format. I want to generate the corresponding fiscal week for the column.
example of my result set:
for 2/1/15 the week of year number should be 1
For 2/7/16 the week number of year should be 1
I tried the below formula, but its starting the week from the first day of the fiscal year and not the first sunday of the year.
=INT((A1-WEEKDAY(E9165)-DATE(YEAR(A1+7-WEEKDAY(A1))-(MONTH(A1)<2),2,1))/7)+2
Please help...
-Sandra
Assuming that your work years always start on the first sunday after February 1st:
=IF(WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1)<=0,52+WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1),WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1))
We first determine the week number of the date starting from the first Sunday of February. To do this I have used WEEKNUM()-WEEKNUM(02/01/SAMEYEAR) taking 1 day from the date to force week 1 as Excel begins counting from week 0 by default. Using IF() we state that if the outcome is 0 or less then add the result to 52, which will give us the correct result for dates in January as they produce negative values.
Edit - Very long formula but gives you the week of the quarter in Q1 W1 format:
=SUBSTITUTE(CONCATENATE("Q",INT(IF(WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1)<=0,52+WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1),WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1))/13)+(IF(INT(IF(WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1)<=0,52+WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1),WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1))-INT((IF(WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1)<=0,52+WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1),WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1))/13))*13)=0,0,1))," W",INT(IF(WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1)<=0,52+WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1),WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1))-INT((IF(WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1)<=0,52+WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1),WEEKNUM(A1)-WEEKNUM(DATE(YEAR(A1),2,1)-1))/13))*13)),"W0","W1")
Apologies for the length, I tried multiple methods to try to find a neater solution, but this was all that I could get to work. It would be a lot neater if there were multiple columns used.
Use this formula:
=IF(A1>=IF(WEEKDAY(DATE(YEAR(A1),2,1),1)=1,DATE(YEAR(A1),2,1),DATE(YEAR(A1),2,7-WEEKDAY(DATE(YEAR(A1),2,1),1)+2)),ROUNDUP((A1-IF(WEEKDAY(DATE(YEAR(A1),2,1),1)=1,DATE(YEAR(A1),2,1),DATE(YEAR(A1),2,7-WEEKDAY(DATE(YEAR(A1),2,1),1)+2))+1)/7,0),ROUNDUP((A1-IF(WEEKDAY(DATE(YEAR(A1),2,1),1)=1,DATE(YEAR(A1)-1,2,1),DATE(YEAR(A1)-1,2,7-WEEKDAY(DATE(YEAR(A1)-1,2,1),1)+2))+1)/7,0))
Way late to the party but was looking for the answer and found this thread. Ended up play around with the function myself and it's much easier to just deduct the dates; =WEEKNUM("date"- days you wish to offset)
Ex; If cell A1 holds my date, 2/1/2021 I wish to convert; =WEEKNUM(A1-31) result "1".
How to write a formula in excel which tells whether a date is a week end date or not. I am trying to get to a formula which takes date into consideration and tells me if the date is a Friday, add 2 days, else add 1 day
Weekday function will do the job
Weekday() returns a number for the day of the week, from 1 to 7. By default, 1 is Sunday, but parameters can make 1 refer to Monday or another weekday.
If you want to work with differences in days, also look at Networkdays() which returns the difference in days between two dates, not counting weekends and not counting a list of holiday dates you can specify.
Click for diagram explanation
Hi guys,
I have managed to find out formula for counting week 1 from custom start date and not from start of the year. (see first diagram above) I've achieved this by entering date manually and having a formula in week cell.
"**Week #"** =TRUNC(((A2-A1)+6)/7)+(WEEKDAY(A2)=WEEKDAY(A1))
Now I want to do it the other way round, rather than type in date every time, I want to type in a week number, relating week number from custom start date that would then be translated into proper date.
10 weeks later would simply be taking your start date adding 7 times the number of weeks or in this case 70 days. Assuming your start date is in C2 and your number of weeks from C2 is in C4, then your formula would be as follows:
=(C2-1)+7*C4
As for your week number formula, you may want to consider changing it to:
=WEEKNUM(I3,2)-WEEKNUM(I2,2)+1
Where I2 is your start date and I3 is your second date. The 2 in the weeknum formula is to tell it your week starts on a Monday.
Based on your comment about different years you could try:
=(WEEKNUM(I3,2)+52*(year(I3)-Year(I2)))-WEEKNUM(I2,2)+1
I am wanting to enhance the functionality of my time sheet. I want to calculate if a person's hours falls into a range, and if so, count how many hours. For example:
A user clocks in on their time sheet:
Tuesday: 05:00 - 04:00 i.e. - They worked 23 hours.
From the above time, I want to count how many hours they have worked between the time range 19:30 - 07:30.
Manually calculating this works out at 9.5 hours - or 09:30.
Many thanks.
Formula:
=IF(ClockOut<RangeStart,0,IF(ClockIn>RangeEnd,0,IF(ClockOut<RangeEnd,ClockOut,RangeEnd)-IF(ClockIn>RangeStart,ClockIn,RangeStart)))
This is what is working for me in all the cases I've tested:
Data cells:
A1: Range start | B1: Range end
A2: Clock In | B2: Clock out
Formula:
=IF(B2<A1,0,IF(A2>B1,0,IF(A2<A1,IF(B2>B1,B1-A1,B2-A1),IF(B2>B1,B1-A2,B2-A2))))
The result is in days, so if you want it in hours, just multiply by 24.
=IF(B2<A1,0,IF(A2>B1,0,IF(A2<A1,IF(B2>B1,B1-A1,B2-A1),IF(B2>B1,B1-A2,B2-A2))))*24
If the times span more than one day, it's crucial for this to work that the cells include the date. In Excel, if you just enter the time, its (fake) date is 00/01/1900, so for the ending times to have the appropriate date, I specified the next day: 01/01/1900. Therefore, if you only have the time, you will have to do this as well.
But if you get a full DateTime from, for example, a database, then you won't have this issue, but you will have to modify the range cells to have the corresponding dates, or modify the clock cells to convert the date back to 00/01/1900, depending on your scenario. Please give some more details if you need help with this.
I am trying to adapt a number of forum posts and previous stack questions like this.
Let's say I have a date Column A2, A3, A4 etc.
I want to be able to utilize the WEEKDAY function to evaluate my condition when only in a Weekday and also 3 days greater than the date in Cell A(x).
So far my attempts have failed or I have not got the results I want. Excel is not my strongest point when it comes to conditional formula formatting.
I think it may be something like:
=WEEKDAY(A$2,2) <=5 AND 'My Cell Date' > 3 Days WHERE those 3 days are weekdays.
Also if it is possible, I want it to work like:
If day 1 of 3 is Thursday, day 2 of 3 is Friday and day 3 of 3 is Monday then apply formatting.
Could anyone help me out with this one please?
Edit not from OP to copy clarification from comments:
If the today date is 3 working days greater than the cell date change to red.
Say A2 has a received date and B2 has a completed date. The completed date is my target. Is it 3 working days greater than received.
Was not quite certain of the requirement (but seem to have hit upon an acceptable solution!):
Use =NETWORKDAYS(A2,B2)>2 under Format values where this formula is true: under Use a formula to determine which cells to format in Conditional Formatting.
NETWORKDAYS
Returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays.
The syntax is:
NETWORKDAYS(start_date,end_date,holidays)
Dates should be entered by using the DATE function, or as results of other formulas or functions.