excel if date falls on weekend default to previous friday - excel

I have the following two functions in different columns and I need to apply a function to both :
=DATE(YEAR(E5);MONTH(E5);DAY(E5))
=TRUNC([#CAT]-TIME(10;0;0))
For both of them I need to default to a Friday if the date falls over the weekend. if date date is during the week it needs to keep the weekday date.
e.g: Sunday 2018/03/11 needs to be 2018/03/09
e.g: Monday 2018/03/5 needs to stay the same 2018/03/05
I have tried using an IF statement with a Weekday (1-7) but when its false it minus a day or two from the date (So on a Thursday it goes to Tuesday)

=WORKDAY(your_formula +1;-1)
will do what you want.
If your_formula resolves to a Sat or Sun, and we add one(1) day, then subtract one (1) workday, the preceding Fri will be the result, Since either Sun or Mon minus one workday --> Friday.

To literally get what you're after, I used this formula:
=IF(WEEKDAY(A2)=1,A2-2,IF(WEEKDAY(A2)=7,A2-1,A2))
On my machine Sunday is 1, and Saturday is 7.

Related

Weekday(...) shows wrong weekday

I live in Europe. Week starts on Monday and ends on Sunday.
Today is Friday, the 5th day of the week.
https://1drv.ms/x/s!AncAhUkdErOkgqR6jJ76GcWrCJozpQ?e=mRH7Ab
=Weekday(Today();2)
shows Thursday as weekday, not friday.
Why?
And why shows Returntype 1 (or omitted) Friday, it should show Saturday (6th day of the week)?
And what is the difference between Returntype 2 and 11?
WEEKDAY is returning the correct result in that cell - i.e. 5.
If you format 5 as ddd, you are actually formatting the date 5 days after 31.12.1899 which is the 5th Jan 1900, which was a Thursday.

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.

Change Date Settings in Spotfire

The default Spotfire Work Week starts on Sunday and ends on Saturday.
I would like to adjust that default value so it starts on Monday and ends on Sunday. I would also like to adjust the work week value itself and my company's work week is one less than the default Spotfire value.
So if I'm looking at 2016, work week 1 starts Monday January 4th and ends Sunday January 10th.
Thanks!

YEAR() fitting to WEEKNUM(...,21) in Excel

I'm looking for a way to specify return 2015 for a date within this week, but in Calendar Year 2014.
This current week according to the Thursday system is Week 01/2015. But the Year function will still return 2014.
Something like:
IF(AND(WEEKNUM(TODAY(),21)=52,WEEKNUM(TODAY()+7,21)<>53),YEAR(TODAY())+1,YEAR(TODAY())
but a little bit more reliable and elegant.
Anybody got something?
Happy Happy
Ben-san
The "Year" of the week is determined by the year of the Thursday of that week (assuming ISO week numbers) so you can just find the Thursday and then get the year of that date, i.e. for any date in A1
=YEAR(A1-WEEKDAY(A1,3)+3)
or, similarly, for today's date
=YEAR(TODAY()-WEEKDAY(TODAY(),3)+3)
This works for any date in any year.......and might put days in Jan in the previous year also, e.g. 3rd Jan 2016 is in the last week of 2015

Microsoft Excel - Date Sequence

I had a look for this question before I asked, but sorry if it's a repeat.
In a spreadsheet, I want to employ a date sequence.
eg. Stock Arrives - Friday 22nd February 2013
then, on the 22nd of Feb, that date CHANGES to the next 7 days.
eg. Stock Arrives - 1st March 2013
and then repeats this indefinitely.
Is there any way to do this?
If you want to always show the next Friday you can use this formula
=TODAY()+8-WEEKDAY(TODAY()+2)
That will show Friday 15th Feb 2013 right now.....but on 15th feb it will change to showing 22nd Feb
For other days just change the +2 at the end, e.g. +3 will give you next Thursday, +4 will give you next Wednesday, +5 will give you next Tuesday etc.
This is some way you could do this though I am not sure if this is what you want.
=B1+FLOOR((TODAY()-B1)/7,1)*7
Basically, have a cell hold the start date of the stock inventory (first date in the past where you received this stock). You need to have also the number of days between restocking (here I hardcoded 7). Then you can just use the floor of the difference between today and that date divised by the restocking time. This will give you a step-function-style behaviour.

Resources