are there are public services which can translate text to a date? - text-processing

example
"this tuesday" should return "25 August 2020"
"first tuesday of september" should return 1 September 2020"?
Google search page does it but do they have an api to do this?

It seems like dateparser.io is what you need.
They offer a free option with 50,000 requests per month.
From their website:
"There is a wide range of ways to express a date in comparison to the
current day. Expressions like 2 months from now or last Sunday are no
problem. Explore our full documentation to see the numerous
expressions that are supported."
They support relative dates (from the bottom of the page):
today - 2020-08-23
yesterday - 2020-08-22
last friday - 2020-08-21
next week - 2020-08-30
last month - 2020-07-23
in 5 days - 2020-08-28
fifteen years ago - 2005-08-23
a day from now - 2020-08-24
5 months before now - 2020-03-23

Related

I'm trying to calculate 3 days from today, but not include weekend or holidays, but

The workday function should work for this. I have a Range called "Holidays". The problem is that workdays doesn't count the weekend days. I need to count the weekend days. BUT, if the 3rd day comes on a weekend or a holiday choose the next non-weekend or non-holiday day. A2 is the Effective Date of the contract, which is the start date. I'm trying to calculate the day on which the Earnest Money is due. See the attached chart as to how it should calculate.
=if(OR(A5="",A5>workday(A2,3,Holidays)),workday(A2,3,Holidays),"") is the formula I have but it works for Effective dates that fall on a Sunday, Monday, Tuesday and Wednesday, but not for Effective dates that fall on a Thursday, Friday, Saturday.
Starting from Today
Use this formula to get the dates starting from today
={ArrayFormula(
VLOOKUP(WEEKDAY(SEQUENCE(7,1,TODAY(),1),2),
{SEQUENCE(7),{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"}},2)),
BYROW(SEQUENCE(7,1,TODAY(),1),
LAMBDA(d, VLOOKUP(WEEKDAY(IF(IFNA(MATCH(d+3,F2:F13*1,0),"")="",d+3,d+4),2),
{SEQUENCE(7),{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"}},2)))}
Starting from Monday
={ArrayFormula(
VLOOKUP(WEEKDAY(SEQUENCE(7,1,TODAY()-WEEKDAY(TODAY(),3),1),2),
{SEQUENCE(7),{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"}},2)),
BYROW(SEQUENCE(7,1,TODAY()-WEEKDAY(TODAY(),3),1),
LAMBDA(d, VLOOKUP(WEEKDAY(IF(IFNA(MATCH(d+3,F2:F13*1,0),"")="",d+3,d+4),2),
{SEQUENCE(7),{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"}},2)))}
Starting from Monday using Lambda
Starting from the current week monday.
=ArrayFormula(LAMBDA(vl,wd,
{VLOOKUP(WEEKDAY(wd,2),vl,2),
BYROW(wd,LAMBDA(d, VLOOKUP(WEEKDAY(IF(IFNA(MATCH(d+3,F2:F13*1,0),"")="",d+3,d+4),2),vl,2)))})
({SEQUENCE(7),{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"}},
SEQUENCE(7,1,TODAY()-WEEKDAY(TODAY(),3),1)))
Explanation
You need the Calendar Year 20xx Legal Public Holidays to skip one day if matched the legal holidays date after adding 3 days.
Used formulas help
BYROW - SEQUENCE - TODAY - LAMBDA - VLOOKUP - IF - IFNA - MATCH - ARRAYFORMULA

iCalendar repeat rule for x days before the 2nd Tuesday in the month

I have a meeting on every 2nd Tuesday of the month.
I need 10 days to prepare that meeting - this means I would need a recurring event "10 days before the 2nd Tuesday of the month"
(added via ical file)
I found iCalendar repeat rule for "the day after the second monday of the month" but I'm not sure how/if this applies to my situation/how to remodel it to fit my needs.
The issue is that since it's 10 days prior it may even be in the previous month in some cases (e.g. if the first day of the month is a Tuesday)
What is the correct command for this?
EDIT: the time is always from 8-10am just so it can be included.

How to calculate the weekend when counting a date range in Google Sheets?

I have the below columns
StartDate EndDate CountDay
01 May 20 05 May 20 ?
As you see, 01 May is Friday, so from 01-05 May if we count all days including weekend it will be 4 days.
What I want is on column "CountDay" it only counts the Workdays, not the weekend.
SO the expected result would be 2.
Anyone know how to do it using a formula in Google Sheets?
Do you consider Fridays as part of the weekend?
If yes, then you could also try the following formula:
=NETWORKDAYS.INTL(A10, B10,"0000111")
If not, please use this formula:
=NETWORKDAYS.INTL(A10, B10)
How the formulas work.
By using the function NETWORKDAYS.INTL we can "adjust" the weekend (non-working weekdays) to our liking.
In this case we account Fridays as our non-working weekdays by using as the 3rd parameter 0000111 instead of the default 0000011 where every 0 represents a working weekday and every 1 a non-working weekday.
(Very useful for people working part-time)
Someone who has part-time work on only Mondays, Wednesdays and Fridays and wants to calculate the working days Friday, 1 May 2020 - Tuesday, 30 June 2020 could adjust the formula to:
=NETWORKDAYS.INTL(A10, B10,"0101011")
As explained on the official Google help page for NETWORKDAYS.INTL
weekend – [ OPTIONAL – 1 by default ] – A number or string representing which days of the week are considered weekends.
String method: Weekends can be specified using seven 0s and 1s, where the first number in the set represents Monday and the last number is for Sunday. A zero means that the day is a work day, a 1 means that the day is a weekend. For example, “0000011” would mean Saturday and Sunday are weekends.
Number method: Instead of using the string method above, a single number can be used. 1 = Saturday/Sunday are weekends, 2 = Sunday/Monday and this pattern repeats until 7 = Friday/Saturday. 11 = Sunday is the only weekend day, 12 = Monday is the only weekend day and this pattern repeats until 17 = Saturday is the only weekend day.
I just found how to do it:
=if(weeknum(A10)<weeknum(B10),B10-A10-2*(weeknum(B10)-weeknum(A10)),B10-A10)
something like that

Set Tableau dates show show previous month going back 12 months

I need to modify some Tableau dashboards so that they show from the previous month going back 12 months.
For example, it is August 2017 now, so the company wants to see the 12 months ending at July 2017. In other words: Aug 2016, Sept 2016, Oct 2016...June 2017, July 2017.
Using Tableau's relative date filter, users can easily select "previous month" (July 2017) or "previous 12 months" (Sept 2016-Aug 2017) on the relative date filter. But they can't choose previous month going back 12 months (Aug 2016-July 2017).
I was thinking of writing a formula that sets current month as 0, previous month as 1, month before that as 2 etc and that way I can filter to only show months 1, 2, ...12. And not show month 0, the current month.
Is this the best approach? I thought Tableau would have an option for this - surely a lot of companies want to see a year worth of data ending at the previous month? (Since the current month is not yet complete so they don't want to see a partial month's data).
Thanks for your ideas!
You are right about this being a common requirement. I do 'Last 12 months' filter too which excludes current month since it is not a full month.
In my case I have defined a True/False type calculated field which I use to filter records which show in the dashboards.
Here is the formula that I use:
DATEDIFF('month',[My Timestamp Field],Today()) < 13 and DATEDIFF('month',[My Timestamp Field],Today()) > 0

What is the first/last week of a month? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
If someone were to say something happens in the first or last week of some month, how would you define that span?
Background
I'm working on a library that needs to handle this kind of thing in an intuitive way, but my intuition doesn't claim one case or the other.
I can make it select different behavior but still need a good default.
For a concrete example I'll just to pick an random month: July 2008
s m t w r f s
--------------------
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
(Note: I'll assume the week starts with Sunday but the question could be asked re Monday as well)
What span is the first week of the month?
June 29 - July 5 -- the week that includes the first
July 6 - 12 -- the first week that is all the way into the month
The second week is just the 7 days following the first right?
What span is the last week of the month?
July 27 - Aug 2 -- ditto but the last day
July 20 - 26 -- ditto but the last week
Non wiki comments welcome
There is no answer because it varies even inside a country.
However, this source seems to think it's defined by the ISO standard as the first week that contains a thursday. However the above source says that the ISO standard does not list a specification for 'first week of the month'
More than 300 chars - sorry!
The ISO 8601 standard defines the first week of the YEAR as:
calendar week number
ordinal number which identifies a calendar week within its calendar year according to the rule that the first
calendar week of a year is that one which includes the first Thursday of that year and that the last calendar
week of a calendar year is the week immediately preceding the first calendar week of the next calendar year
There is nothing in ISO 8601 about the first week of the month because, as has been noted, the definition varies by country (and even by company, for example). Oh, and the standard says that weeks start on Monday.
If you are building a library, you should allow the user to choose how they want to handle it either by having methods that return the first/last full/partial week of the month or by passing an argument that indicates whether you want the full/partial week. Clearly document whichever is the default if you provide methods that don't require the specification.
public Week GetFirstFullWeekOfMonth( DateTime forDate ) { }
public Week GetFirstPartialWeekOfMonth( DateTime forDate ) { }
Or
public Week GetFirstWeekOfMonth( DateTime forDate, bool includePartial ) {}
The first week of the month is the first week that is all the way int the month
July 6 - 12
The first week of the month is the week that includes the first
June 29 - July 5
The last week of the month is the week that includes the last day
July 27 - Aug 2
The last week of the month is the last week that is all the way int the month
July 20 - 26
My definition would be the first week is the week of the first working day in the month,
and likewise the last week is the week of the last working day in the month.
The first week of the month is the first week that owns 4 or more days of the defined week period. (Not really but I thought I'd throw it in as an option)
The first week of the month is week 0 - the week that has the first day of the month.
The last week is the week with the last day of the month
Hence the weeknumber of the last week of july IS THE SAME as the weeknumber of the first week of august
** UNLESS **
the month in question ends on the last day of the last week, in wich case the following month would start on the first day of the new week and have a different weeknumber
:)
There's a fairly obvious option you are missing. The first week of the month is the seven days starting with the first day of the month. Hence, in your example, the first week would be Tuesday, the 1st through Monday, the 7th. This way, the first through 4th weeks would always be fully contained within the month, and only the 5th week would cross over.
Talk to your users and ask them what they think it means when the program says to them "First week of the month" and "Last week of the month".