Excel formula to determine shipping date - excel

Due to production and shipping issues my job has created a report that has the customer's need by date and if a product has been completed or not. If an order is complete we need to determine when it will ship out and arrive to the customer. We have a set shipping schedule and orders get shipped on the truck right before the need by date. For example our truck leaves on Monday and Friday every week so if an order is complete and the need by date is on a Wednesday it will ship on Monday so any order with a need by date from Tuesday to Friday gets shipped the Monday before and any need by date from Saturday to Monday gets shipped on Friday. Now my questions is, is there a way to have a date range yield it's shipping date? Example when I'm writing this it's 5/11/2022 so if I have completed orders with need by dates of 5/12 and 5/15 all of which should be on the 5/13 truck could I use a formula to fill in the shipping date for those need by dates? We've been doing it manually and although determining the dates isn't difficult it's time consuming when each report has over 3000 lines and there is a report for each customer. If it's not possible then we won't have a choice but I would like to hope so. Please help.

The third column is just to show that the ship dates are on the correct day. It looks different because the dates are Australian (DD/MM/YYYY) rather than American (MM/DD/YYYY), but that shouldn't matter for the function to work.
The function in the Ship Date column:
=IF(OR(TEXT(A8,"dddd")="Tuesday",TEXT(A8,"dddd")="Wednesday",TEXT(A8,"dddd")="Thursday",TEXT(A8,"dddd")="Friday"),A8-WEEKDAY(A8,3),A8-WEEKDAY(A8+2,2))
Need By Date (including header) = A7:A20
Ship Date (including header) = B7:B20
Explanation
TEXT(value, format_text): this is used to convert the date (DD/MM/YYYY) to the long day (e.g. Monday)
Breakdown
IF the day is Tues, Wed, Thurs, or Fri
THEN return the date of that weeks Monday
ELSE return the date of that weeks Friday

Related

Find the trading date every 2 weeks (if Saturday or Sunday, then show Friday date)

For a backtesting trading system, I need to rotation my positions every 2 weeks, BUT if the day is a Saturday or Sunday, I need to take the Friday.
Semi-Monthly updates are made twice a month; mid-month and month end.
Mid-month updates are on the 15th calendar day of each month. Should the 15th be a weekend or holiday, the update will occur on the last trading day prior to the 15th.
For example, if the 15th is a Saturday then the update will occur on the close of Friday the 14th.
I need to return a list of dates of rotation based on a start date and end date.
Let's say, I need every 15 days from January 1st 2018 to 31st December 2018, it should return only the valid dates based on the rules described above.
The formula should be for Google Sheet or Excel.
I tried the following:
It is not returning exactly what I need, since the google sheet googlefinance formula allows to use daily and weekly intervals (1 or 7). See below the googlefinance definition (https://support.google.com/docs/answer/3093281?hl=en):
"interval - [ OPTIONAL ] - The frequency of returned data; either "DAILY" or "WEEKLY".
interval can alternatively be specified as 1 or 7. Other numeric values are disallowed."
You need to be more precise in your specifications. You've provided multiple inconsistent intervals. eg: Two weeks (which would be every 14 days and will always fall on the same weekday); every 15 days (which will NOT be mid-month and EOM over most time periods); mid-month and end-of-month.
I suggest developing formulas for each of your desired intervals.
Once you have developed those relevant formulas, depending on your desired interval, to avoid a date falling on a weekend (or holiday if required for your system), you can use the WORKDAY function:
=WORKDAY(computedDate+1,-1, [holiday])
If your computedDate is on a Saturday, or Sunday; by adding 1 day and then subtracting to the previous workday, Friday will result.
If your trading interval is every Two weeks, you only need to ensure that the First date is not on a Saturday or Sunday. For other intervals, you may have to apply the formula to every computedDate.

How to find the following Friday after a pay period ends

My company pays every Friday on the sales from the previous week. Our work period goes from Sunday to Saturday, and we get paid every following Friday for any work done in that pay period.
I have the dates of my sales in column J, and I want the corresponding payday to appear in column M. So if J1 had 1/14/17, M1 would return 1/20/17. The formula I found is:
=J1+7-WEEKDAY(J1+1)+7.
This works almost perfectly except that any sales made on a Saturday don't get paid out for 13 days, and they should get paid out in 6 days. So how do I change this to get what I need?
The element that snaps a particular day to a particular week is the weekday() function. So you need to adjust the input to weekday function by one day and then compensate by adding one less day at the end.
So you need:
=J1-WEEKDAY(J1)+13
Instead of:
=J1-WEEKDAY(J1+1)+14

How do I calculate a date by adding 30 calendar days, where end date must be business day?

I'm wondering if this is possible. I am creating a spreadsheet to track project due dates. Each project must be completed by the 30th calendar day, but must be turned in on a business day.
Currently, I am just adding 30 days to the start date but this means some due dates aren't always accurate. For example, if the 30th day is Saturday, April 2nd, then the real due date would be Friday April 1st.
Is there a way to construct a conditional such that the due date equals the 30th calendar day, unless that falls on a weekend / holiday, where it then falls on the next earliest business day?
I've been struggling to figure out a way to do this.
For English settings in Excel, with a date in A1, in B1 enter:
=IF(TEXT(A1+30,"DDDD")="Sunday",A1+28,IF(TEXT(A1+30,"DDDD")="Saturday",A1+29,A1+30))
This simple-minded approach only handles Saturdays and Sundays, not arbitrary holidays.
I would prefer more elegant way like using WORKDAY.INTL
=WORKDAY.INTL(A2+31,-1,1,E2:E)
Explanation: start date + 31 days (1 day more than maximum calendar days)
then subtract 1 working day - going to last previous working day
Reason: because this formula does know when are weekends (by using variables) and also knows to skip hollydays by a custom list.
here is an example sheet you can use
Revised after comment:
Try this:
=(A4+30)+CHOOSE(WEEKDAY(A4+30),1,0,0,0,0,0,-1)
Your date, in A4, + 30 days, then add an amount of days until the next workday. If A4 + 30 is a Saturday it will subtract 1 day, a Sunday will add 1.

Excel - Times a month and day occur between 2 dates

I have an Excel sheet where someone types in the date for a yearly bill. I need to know how many times we need to pay that bill between 2 dates.
For example if a bill is due every year on May 31st, the user will type in 5/31/2014. I need to know how many time we will pay that bill between 5/15/2014 and 5/15/2018. (The between dates will change). I can't just take the number of years between the start and end dates because in the example above the start and end dates could be 6/1/2014 and 5/30/2018, in which case I only have to pay the bill in 2015, 2016, and 2017, which makes 3 times.
I have this formula which calculates the number of times a certain day occurs between 2 dates: SUMPRODUCT(--(DAY(ROW(INDIRECT($Q$2&":"&$R$2)))=F4))(Q2 is the begin date, R2 is the end date, and F4 has the day of the month) But I can't figure out how to get this to work for a month and day.
Assuming the specific date in G4 you can use this version
=SUMPRODUCT(--(TEXT(ROW(INDIRECT($Q$2&":"&$R$2)),"ddmmm")=TEXT(G4,"ddmmm")))

Does Excel have a function to calculate Canadian federal holidays?

I'm trying to figure out how to calculate the past/future Canadian federal holiday dates to use the NETWORKDAYS function in the cell. Because the dates of the holidays change every year, is there a function or VBA code that I can use to calculate this?
For example, I have a 10 year project and I want to calculate the variance between the beginning date and the end date, excluding the weekends and holidays.
Like, Civic holiday is on the 1st Monday of August. It was on the 1st in 2011, but in 2012 it was on the 6th.
Easter Monday was on the 25th in 2011, but on the 9th in 2012.
Becuase NETWORKDAYS need exact date of the holidays in order to work, I need to calculate the future holiday dates (10-15years into the future)
I hope this makes sense...
You can make a list quite easily with a formula approach e.g.for Labour Day list years only in A2 down and in another column in row 2 use this formula
=DATE(A2,9,8)-WEEKDAY(DATE(A2,9,6))
that will give the date of First Monday in September for the relevant year - copy formula down column
Edit: Here's a workbook with all holidays calculated from 2000 to 2099 as per your rules, I think. If you want dates before 2000 then just change the years in column A and the dates will change automatically
I would add a couple of blank columns to the range, e.g. make C2:M101 = holidays, then you can use that named range in any NETWORKDAYS/WORKDAY function - the extra columns would allow you to enter any "ad hoc" holidays
I know I'm a little late to the thread but for some reason the link to your file doesn't open. I would love to see how you calculate the Canadian holidays. I have found solutions for: Labour Day, Easter, Good Friday and Victoria Day but still looking for the rest.
Labour Day
=DATE(A2,9,8)-WEEKDAY(DATE(A2,9,6))
Easter
=FLOOR("5/"&DAY(MINUTE(A2/38)/2+56)&"/"&A2,7)-34
Good Friday
=FLOOR(DATE(A2,5,DAY(MINUTE(A2/38)/2+56)),7)-36
Victoria Day
=DATE(A2,5,25)-WEEKDAY(DATE(A2,5,25),3)-(7*(WEEKDAY(DATE(A2,5,25),3)=0))
* 4 digit year must be in A2 *
The working days are from Monday to Friday, excluding the holidays.
Some holidays taking place during weekend should be moved to next Monday (e.g. Canada Day, Boxing Day, New Year), or previous Friday (e.g. Christmas)
The following are the formulas for the holidays in the province of Ontario, Canada, if the fiscal year is in FYear
Holyday Formula
New Year =WORKDAY(DATE(FYear,1,0),1)
Family Day =DATE(FYear,2,22)-WEEKDAY(DATE(FYear,2,6))
Good Friday =FLOOR(DATE(FYear,5,DAY(MINUTE(FYear/38)/2+56)),7)-36
Victoria Day =DATE(FYear,5,25)-WEEKDAY(DATE(FYear,5,23))
Canada Day =DATE(FYear,7,1)+(WEEKDAY(DATE(FYear,7,2))<3)*(3-WEEKDAY(DATE(FYear,7,2)))
CivicDay =DATE(FYear,8,8)-WEEKDAY(DATE(FYear,8,6))
LaborDay =DATE(FYear,9,8)-WEEKDAY(DATE(FYear,9,6))
Thanksgiving =DATE(FYear,10,15)-WEEKDAY(DATE(FYear,10,6))
Christmas =DATE(FYear,12,25)-(WEEKDAY(DATE(FYear,12,26))<3)*WEEKDAY(DATE(FYear,12,26))
Boxing Day =DATE(FYear,12,26)+(WEEKDAY(DATE(FYear,12,27))<3)*(3-WEEKDAY(DATE(FYear,12,27)))
Next New Year =WORKDAY(DATE(FYear+1,1,0),1)
I found this page very useful, but I have a couple of additions. My use case is that I want to know when a stat holiday occurs even when it moves to a different day like Friday or Monday. These formulas apply to a table where #Year contains the year as a simple number.
U.S. Independence day behaves differently. If July 4 is a Saturday then the holiday is on 3 July. If July 4 is a Sunday then the holiday is 5 July. I found writing these as nested IF statements more straightforward:
=IF(WEEKDAY(DATE([#Year],7,4))=7, DATE([#Year],7,3), IF(WEEKDAY(DATE([#Year],7,4))=1,DATE([#Year],7,5),DATE([#Year],7,4)))
Next, the formulas above don't work for years like 2021 where Christmas and Boxing Day were a Saturday and Sunday. Again I think nested IFs work better.
We know that if Christmas Day (Dec 25) is on a Saturday, then the stat holiday is on Dec 27, and if it is on a Sunday then the stat holiday is Dec 26. =IF(WEEKDAY(DATE([#Year],12,25))=7,DATE([#Year],12,27),IF(WEEKDAY(DATE([#Year],12,25))=1,DATE([#Year],12,26),DATE([#Year],12,25)))
Similarly, we know that if Boxing Day is on either a Saturday or a Sunday (meaning Christmas was Saturday), then the stat is on Dec 28. And if it falls on a Monday (meaning Christmas was Sunday), then it moves to Dec 27.
=IF(OR(WEEKDAY(DATE([#Year],12,26))=7,WEEKDAY(DATE([#Year],12,26))=1),DATE([#Year],12,28), IF(WEEKDAY(DATE([#Year],12,26))=2, DATE([#Year],12,27), DATE([#Year],12,26)))

Resources