How to Filter a date column to show the last week day of a month only - excel

I would like to know how to filter a date column in excel 2003 to show the last weekday date of a month only.
I tried making another column with TRUE/ FALSE outputs using the formula =DAY(N8+1)=1, which returns true if the day referenced is the end of the month. However, this formula returns false if the last weekday of the month is NOT the last day of the month, ie 12/29/2006. How can I get it so the expression returns true for the last weekday of the month (after that I can sort the column by whether it is true/false).

This works for me:
=IF(WEEKDAY(DATE(YEAR(B3),MONTH(B3)+1,0),2)>5,
DATE(YEAR(B3),MONTH(B3)+1,0)-WEEKDAY(DATE(YEAR(B3),MONTH(B3)+1,0),2)+5,
DATE(YEAR(B3),MONTH(B3)+1,0))
Note how I use DATE(YEAR(B3),MONTH(B3)+1,0) to get the date of the last day of the month, test if it's "greater" than Friday, and if so, subtract from it the number of days by which it is greater than Friday.

You can add a formula in a column to autofilter on.
Chip Pearon's site has a formula which shows this and he is an invaluable resource
=DATE(YEAR(A1),MONTH(A1)+1,0)-(MAX(0,WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,0),2)-5))

Related

Excel how to convert weeknum to date when crossing the year

I have a table with Date column and weeknum column.
The weeknum column has below formula to create a srting: 2022/10.
=YEAR([#[Date]})&"/"&WEEKNUM([#[Date]],2)
I would like to get the start day and end day of the week converting from the string "2022/10".
I tried =DATE($M$1,1,-2)-(WEEKDAY(DATE($M$1,1,3))+(MID(M4,6,2)*7)) where $M$1 references current year and M4 references Year/ weeknum but it returns 10/17/2021. It should return 2/28/2022, and as the weeknumber increases. the returned dates decrease.
The dates of 2021/53 are correct, but the others got wrong.
How do I get fixed the dates?
You can do this by taking the weekday number of the date away from itself and adding 7-weekday to itself.
i.e.
If we use the first date on your list and we say weeks start on Monday:
The first day of the week (Monday) = E2-WEEKDAY(E2,2)+1 = 12/27/21
The last day of the week (Sunday) = E2+(7-WEEKDAY(E2,2)) = 01/02/22
Note: I have assumed your first date (12/27/2021) is in Cell E2
If you want Sunday to be the first day of the week, simply add a 1 instead of a 2 into the WEEKDAY part of the formula.

SUMPRODUCT difference between two dates for THIS WEEK entries only

I have a column D containing all the Dates in DD/MM/YYYY format, and I would like to show the count of missed days for THIS WEEK values only from all the entries in column D.
In other words, if there is a difference between two Dates in column D and it occured this week, I would like to count it.
I have below formula to calculate "Total days missed" between first and the last entry in Dates column D, however I can't adopt this formula to display "Days Missed" for THIS WEEK only entries.
=SUMPRODUCT(--ISNA(MATCH(ROW(INDIRECT(MIN($D$18:$D$500)&":"&MAX($D$18:$D$500)));$D$18:$D$500;0)))
Sample of data set.
Please help, thanks.
For O365, in accord with your statement that there can be multiple entries of one date, I suggest the following (assuming your dates are real dates and not text strings that happen to look like dates):
Total Missing Dates
=MAX($D$18:$D$500)- MIN($D$18:$D$500)+1-COUNT(UNIQUE($D$18:$D$500))
Missing Dates THIS WEEK obviously, you'll need to define the first and last dates of THIS WEEK
=7-COUNT(FILTER(UNIQUE($D$18:$D$500),(UNIQUE($D$18:$D$500)>=wkStart)*(UNIQUE($D$18:$D$500)<=wkEnd)))
If your week starts on Monday, you can calculate:
wkStart: =TODAY()+1-WEEKDAY(TODAY()-1)
wkEnd: =wkStart+6
More generally, to return a particular day of the week prior to someDate (or wkStart):
wkStart = someDate - WEEKDAY(someDate - DayOfWeek)
where DayOfWeek is: Sunday=1 Monday=2 , etc
So, making someDate = TODAY()+1 ensures that if today is monday, it will return today and not the monday from a week ago.
HINT: It might be more convenient to define wkStart and wkEnd as a Named formula.

Return last day per month (and week) in dataset

I have a large amount of daily stock market closing data that I need to report on, however I only need the last day of the month from each data set.
Given the dates of each month will differ year to year depending on weekends and public holidays I can't just use =EOMONTH(A2,0)
How do I extract, just the last day of each month from a data set probably using the MAX functionality in some way. Then I can just do a Vlookup to get the data for that date,
[![Share Price Sheet][1]][1]
If your date column is sorted by small to large, index() and match() could solve this problem.
Try to use:
=INDEX(A:A,MATCH(EOMONTH(DATE(D2,E2,1),0),A:A,1))
which point is set third argument to 1 in MATCH function.
If you want to get close price, in G2 cell write:
=VLOOKUP(F2,A:B,2,FALSE)
Since the last date is found on the dataset you have, you can just select distinct your year & month in a new sheet, create a helper column combining the 2 columns.
Create the same helper column in your original dataset, sort dates by newest to oldest. And you can vlookup the exact date. If you just want the day part of the date, extract the date from the Date itself with the day formula
You can do this just by Pivot Table
Select your data (I used a snipped only)
Insert a Pivot Table
Use Year, Date and Close as your Row labels
Use Date also as a value field
Set Date in your value field to show Max, format to actually show dates and rename if you want, e.g. "Last Day"
Click any date under any month in the row labels > Filter > Top-Ten > Choose to filter top 1 under Last Day and confirm.
Format your pivot table to your liking, maybe hiding subtotals.
My end result looks like:
You could use a combination of EOMONTH and WORKDAY.
For example:
The date you're looking at is 21st November 2019.
=EOMONTH(DATEVALUE("21 Nov 2019"),0)+1 will return 1st December 2019.
30th November is a Saturday, and for some reason the 25th to 29th November are holidays.
=WORKDAY(EOMONTH(DATEVALUE("21 Nov 2019"),0)+1,-1,{43798,43797,43796,43795,43794}) will return 22nd November as last working day of the month.
Using cell references (D3 = Date, A1:A5 are the holidays):
=WORKDAY(EOMONTH(D3,0)+1,-1,$A$1:$A$5)

Find last digits with IF

I have lots of cells in the spreadsheet that contains the whole year, date and stock prices, but I only need the dates from 25th of the last month till the 5th of this month.How can I write a function to do that? For example if the cells are like this in the column:
19900101
19900102
19900103
19900104
19900105
.
.
19900125
19900126
19900127
19900128
19900129
19900130
19900131
I want it to show only days (1,2,3,4,5,25,26,27,28,29,30,31) with the date format.
The date shows in the text format and I've tried format cell to change it but it doesn't work.
For a slightly different approach, assuming you want to return the A2 value only if it represents a date in the last 5 or first 5 days of any month you can use this formula in B2
=IF(DAY(TEXT(A2,"0000-00-00")+5)<11,A2,"")
TEXT function converts your data to a real date then if you add 5 days to that date then any date that was originally in the last 5 or first 5 of the month will now be in the first 10 days of the month.....so it's sufficient to check that the day is < 11. That will pick up 27th to 31st of a 31 day month, 26th to 30th of a 30 day month etc.
you could use a formula and then filter by rows with data...
As an example (given it's difficult to discern if you always want the first 5 and last 5 of a month or what....)
=IF(RIGHT(A2,2)*1<=2,A2,IF(RIGHT(A2,2)*1>=29,A2,""))
Based on all the edits and comments, these should be the function you need.
=IF(OR(A7-A2>5,MOD(A2,100)<=5),DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2)),"")
You should place it in cell B2 and then do all the desired filtering, as explained in xQbert's answer.

Excel date and text Format

I have an excel sheet in which there is a column of data like the one given below
Last day of this week corresponding to Sunday is 41280
Last day of this week corresponding to Sunday is 41287
Last day of this week corresponding to Sunday is 41294
Last day of this week corresponding to Sunday is 41301
Last day of this week corresponding to Sunday is 41308
Last day of this week corresponding to Sunday is 41315
Last day of this week corresponding to Sunday is 41322
This is a file from our client. But we are expecting the last numeric values to be of date format.
Last day of this week corresponding to Sunday is 1/6/2013
I tried changing the format to date, but it is not accepting
How can i achieve the same
Put this formula in the next column along (formula assumes your text is in column A):
=TEXT(RIGHT(A1, 5), "dd/MM/yyyy")
I've dropped in the UK dateformat, but of course you can go for the dateformat that suits you.
Changing the format of the cell should do the job. So changing from Number or General to Short Date or Long Date works for me.
I have a neat function that I use with a date in Excel. If I want text to appear in the same cell as the date, I use the following concatenation function.
What I want to see: Date of Submission: 10/17/2016
What I type in: ="Date of Submission: "&TEXT(NOW(),"MM/DD/YYYY")

Resources