Extract dates in various formats from free text string in excel - excel

I'm struggling with extracting dates from a free text field in Excel where the date could be in any number of formats due to human input.
Some examples of the entries are below but essentially they could be 30/6, 30/06, 30th June, 30/6/21, 30/06/21, 30/06/2021, 30-6, 30th, 30-06, tomorrow!
Alright; I probably can't do much about that last one and I can pull the date from the others if I know the format but I'm looking for something that would handle any and all of the permutations.
Example Data
Column A
Empire still haven't repaired the roof. Waiting on Empire to waterproof the roof then I can patch up the ceiling in 611. ETA 30/06/2021
ETA 11/6/21
floor boards need replaced
22/6/21 awaiting parts
have sanded the filler that was in the war and refilled ready for or sanding again
new bathroom floor to replace. need to source materials and have time to do job. full bathroom sub floor to replace. ETA 29/06
Engineer attended and found E122 error, reset and tested but fault still present. New EVA probe required. Part to be sent to site.
new toilet handle ordered. ETA 28th June
TV on order
refer to Colin Warner for further works and required parts
28/6 awaiting underlay
leak in room 315 fixed. room 215 will need a week to dry. ETA 30th June.
10 July
ceiling too wet to carry out any work. eta 5-07-2021
I know it's a big ask but if you know of a formula or VBA UDF that can handle all of those then I'd be eternally grateful.

Related

participation rate of an advents calendar

i am not used to working with excel anymore and there is no VBA available at my workplace.
I have a set of data showing a userID (left) and numbers (right) which indicate a day in december (1 = december 1st to 24 = december 24th)
I figured out how many people participated on specific days, but i'd also like to know what the amount of participations looks like overall (how many people played only 1/24 times, how many people played 24/24 times etc). It's mostly a fun project for work where not much of excel analysis is being done, that's why i'm asking here. Thanks in advance!
I tried a combination of COUNTIF with FREQUENCY but i couldn't figure it out on my own
What about inserting a pivot table?
You can have a look at my example here:
By clicking on the right-arrow (see green rectangle), you can change the properties of the "summing" field and turn it into a "counting" field:

How to display the past 17 trading days (business days) when looking up Stock History in excel

I'm using the new STOCKHISTORY function in Excel and I'd like to always display the past 17 trading days from the point I indicate. The problem is with long weekends and holidays this alters the amount of business between two dates. I'm not sure if this will be a difficult question because I think the solution is not dependent on the fact that I'm using the STOCKHISTORY function. I have attached a photo with a simple explanation. On the left the formula for STOCKHISTORY is =STOCKHISTORY(E2,C4-C6,C4,0,1,0,2). This displays 17 business days because 22 is the magic number. On the right though if I query July 22nd with 22 day difference I only get 16 days. This is further wrong on many other dates.
I am open to having a separate reference on another sheet that has dates/formulas. I tried this but couldn't figure out a formula to pull down. Photo B displays an example of the correct number of dates that would show 17 trading days. I am also open to displaying more than 17 trading days as in the future I will need to alter the amount of trading days needed (I might need to display 15 days or 20 days).
In my head I feel like the answer has something to do with the NETWORKDAYS function and/or I should make a list of all the trading days in a year and then make a formula taking the current day and taking away a specific day. Or I could be totally wrong and the answer is obvious.
So I figured out an answer after reading some documentation. There is most likely better answers but it solves the problem enough.
So I created a list of all trading days (business days) as you can see in column O. Then in Column L a list of nearby holidays (Only needed a few exceptions). Then using the formula =(O35)-(WORKDAY(O36,-17,$L$35:$L$36)) I get the right solution which I verified in my example photo posted earlier. You could theoretically get a different number when doing your own calculations (i.e the answer 24 and 23 are both correct).

Attributing values depending of another value w/ VBA ? Excel 2010

First of all, sorry if it already exists but I can't find the words in English to describe rapidly my question, hence I don't know how to search for it. Skip to third paragraph if you only need the question.
I'm using Excel to build a complete document about my work hours (arrived at, finished at, if I've been late and of how long was I late, overtime, etc etc).
I'm using VBA to smooth this task.
My workplace cuts everything into quarter of hours, which means that if you're late by one minute, you'll lose 15 minutes. If you work overtime for 14 minutes, it won't be seen as overtime. If I point at 07:45 (I'm using 24H format, not AM/PM) I'm fine. If I do it at 07:46 it'll be counted as 08:00. Same with 16:14, it'll show up as 16:00 (details are shown but on the corrected sheet used for salary, it'll show this way). If I do it at 16:15 I've confirmed my 15 minutes of overtime.
So while I could do some workarounds, what I've got in mind is shitcode, really. I'd like to know a good (clean) way to do this : I want for every timestamps I input to be cut in degressive quarter of hours (for instance, I want 17:12 to show up as 17:00 or 08:57 as 08:45).
Thanks for your help, if you didn't understand something or doubt about something I've said, it's probably because of the way I explained it, please ask whatever's needed :)
Update 01: Values are indeed Time processed by Excel, not Strings looking like a timestamp.
Update 02: Solved by #FunThomas with TimeSerial-command and some explanations. Thanks, I hope this can be of help for future reference, however I lack the words to write a better title for this problem.
Assuming that you data is really time (and not a string that looks like time) and is stored in Cell A1, you can use a formula like this:
=TIME(HOUR(A1), INT(MINUTE(A1)/15) * 15, 0)
The time-command gets three paramater (hour, minute, second).
The hour-part is simple.
For the minute, we make an integer division by 15 (resulting in values from 0..3) and multiply it back with 15 (to get 0, 15, 30 or 45).
The second is simply set to 0.
Update:
As VBA-function:
Function roundTime(t As Date) as date
roundTime = TimeSerial(Hour(t), Int(Minute(t) / 15) * 15, 0)
End Function

Excel - Finding nth day of specific month from any day of the year

I'm creating a daily scheduling report. Not every position in the report has to be staffed every day, but there's rules determining this (daylight savings mostly) and I've been pulling my hair out trying to figure out a good way to do this that will make it anyone-proof for the person that needs to fill out the sheet on any given day.
My issue: Starting the first sunday in november, one position doesn't need to be staffed all the time. This continues until the second sunday in march. I want the box that shows this position to be conditionally formatted based on what today's date is (which is shown in E1 using =Today() )
I got something close to working (though it looks disgusting), and would cite sources, but I just came back to working on this project after a couple months of a different assignment:
=IF(MONTH(E1)>10,AND((DATE(YEAR(E1),11,1+7*1)-WEEKDAY((DATE(YEAR(E1),11,8-1))))<E1,E1<(DATE(YEAR(E1)+1,3,1+14*1)-WEEKDAY((DATE(YEAR(E1)+1,3,8-1))))),AND(DATE(YEAR((DATE(YEAR(E1),11,1+7*1)-WEEKDAY((DATE(YEAR(E1),11,8-1))))-1),MONTH((DATE(YEAR(E1),11,1+7*1)-WEEKDAY((DATE(YEAR(E1),11,8-1))))),DAY((DATE(YEAR(E1),11,1+7*1)-WEEKDAY((DATE(YEAR(E1),11,8-1)))))),E1<(DATE(YEAR(E1),3,1+14*1)-WEEKDAY((DATE(YEAR(E1),3,8-1))))))
It seems to kick in during the SECOND Sunday in November. I'm particularly flummoxed now. It's been an interesting intersection of "I'm pretty good with computers and layout design" and now all of a sudden diving deeper than I'd ever thought i'd go in excel. Keeping that in mind, I'm starting to feel a little out of my depth already and I'm sure VBA could do this easily but I wouldn't know the first thing about what I'm doing which means if anything ever goes wrong because someone accidentally deleted something I won't be able to fix it.
TL;DR: Trying to hit a moving target of a date based off of a dynamic entry in E1. Based off of E1 find the first sunday in november and the second sunday in March of the following year (or i suppose current year once we roll back around to january)
=OR(DATE(YEAR(E1),11,15-WEEKDAY(DATE(YEAR(E1),11,1),2))<=E1,DATE(YEAR(E1),3,15-WEEKDAY(DATE(YEAR(E1),3,1),2))>=E1)
alternatively you can replace E1 in the formula with TODAY(). This equation will evaluate to True or False

How to calculate a... median? of hour/day/month of occurence?

My problem concerns day of month however, I can see that the same logic would apply to month number or hour number or any other variable that ends on some value and then starts from 0 again.
It is defined as follows: I'm trying to calculate a day of month when a payment is made to use it for a forecast. So I have for example for one case:
1 May 2016
2 June 2016
30 June 2016
29 July 2016
6 September 2016
A simple average would give me 14th, and the median would give me 6th. But the result I'm looking for is more like the 1st.
I see I could do it somehow by calculating geometric median, or euclidean distances after placing the points on a circle etc, but I believe it can be approached in a much simpler way. I also see that solving this problem with standard means and averages would cause a situation where it gives more than one result.
But if we add an assumption that it should occur once in 30 days/a month? Wouldn't this assumption make the problem easier?
Please let me know if you solved a similar problem before or if you have any ideas
If the result you are "looking for is more like the 1st", then I would hazard a guess that you are really looking at a series of monthly payments (perhaps falling due on the first of each month or the first working day of each month) and you want some measure of the deviation between the due date and the actual date of payment.
If that is the case then simply calculate the difference in days between the due date and the actual date of payment for each monthly payment (following a consistent convention such as positive values denote late payment and negative values are early) and then apply your chosen measure (median, mean, etc) to the series of differences.

Resources