Roll-Forward Date Patterns in Excel - excel-2010

Using Excel 2010, I need to take an existing date in 2015 (i.e. 2/11/15), and calculate the same date position in the next year. In other words, whatever is the specific date pattern with the existing date, I'm looking for a formula that will help me calculate the exact same date pattern. If 2/11/15 is the second Wednesday in February of 2015, I need a formula to help me calculate (using the existing date) the second Wednesday of February in 2016.

#Jeeped, thanks for your reply. You're correct - there's many "conditions" to account for. Two colleagues helped-out with the following:
=IF('Data (Reference)'!C14>"", CONCATENATE(TEXT('Data (Reference)'!C14, "MM"),"/", TEXT(7-(WEEKDAY(CONCATENATE(TEXT('Data (Reference)'!C14,"MM"),"/", Input!$C$2))-1)-7+TEXT(WEEKDAY('Data (Reference)'!C14), "DD")+(CEILING(TEXT('Data (Reference)'!C14, "DD")/7, 1)-(IF(TEXT(WEEKDAY('Data (Reference)'!C14), "DD")
We had to consider wherever the existing date fell, and dynamically identify the pattern and/or condition and re-apply it in the roll-forward sequence.

Related

How can I calculate today's date ONLY if today is less than or equal to the last day of the current month in Google Sheets?

I would like to express the following expression in Google Sheets:
IF today's date is less than or equal to the last day of the current month (in this case October 2021), THEN output today's date, OTHERWISE output the last day of the month (i.e. October 31, 2021)
I've tried a few different ways but nothing seems to work. Below is my latest attempt, but I get an #ERROR.
=IF(TODAY(<=2021,10,31),TODAY(),DATE(2021,10,31))
Thank you in advance for your help.
You need EOMONTH() function. Try below formula-
=IF(TODAY()<=EOMONTH(TODAY(),0),TODAY(),EOMONTH(TODAY(),0))
Just use =TODAY(). if you are interested in current month.
If you need today's date, but not further then the last day of October, use:
=MIN(TODAY(), DATE(2021, 10, 31))

Select a "tax month" with a non standard month start/end

I have a Google Sheet with data like this:
Date
In
Out
July 13
£40
July 21
£60
etc.
I'd like to add another column "month" which specifies what month the entry was made in. Only problem is I can't use the standard MONTH() function because for accounting purposes, the tax month is 16th - 15th. So July 13 would be considered to be in the June/July tax month, while July 21 would be considered to be in the July/August tax month.
I'm assuming I will need to maintain a table of the specific cut off dates like so:
Month
Start
End
Jun/July
16th June
15th July
etc.
But I can't work out how to use this as a lookup table to achieve what I want. Any thoughts appreciated.
I think this should work if your date is in A1:
=IF(DAY(A1)>15,TEXT(A1,"MMMM")&"/"&TEXT(A1+20,"MMMM"),TEXT(A1-20,"MMMM")&"/"&TEXT(A1,"MMMM"))
If sort order is important (e.g. in a subsequent pivot table) I would use this:
=IF(DAY(A1)>15,TEXT(A1,"MM MMMM")&"/"&TEXT(A1+20,"MMMM"),TEXT(A1-20,"MM MMMM")&"/"&TEXT(A1,"MMMM"))
Another way to specify the sort order is maintaining a separate table with sort order column. It's a completely different approach.
use:
=ARRAYFORMULA(IF(A2:A="",,IF(DAY(A2:A)<16,
TEXT("1/"&MONTH(A2:A)-1, "mmmm")&"/"&TEXT("1/"&MONTH(A2:A), "mmmm"),
TEXT("1/"&MONTH(A2:A), "mmmm")&"/"&TEXT("1/"&MONTH(A2:A)+1, "mmmm"))))

Google Sheets: IF and Date formula not working

I'm calculating annual holiday accrual.
All holiday resets at the start of the calendar year.
If a staff member started after 01.01.2017 they will have a lower holiday entitlement for the year.
I'm trying to create a formula which says:
If this cell's date is after 01.01.2017 return that cells date. Otherwise, set it at 01.01.2017.
(so basically, I don't care when they started if it was before 01 Jan 2017 because all my following calculations will be based off the first day of the year)
Here it is:
=if(T21<date(1,1,2017),T21,"01/01/2017")
No matter what is in the cell, it is returning 01/01/2017.If I change the < to > it returns cell T21 in all cases.
Any ideas?
Thanks
You have the DATE() values mixed up. Try:
=if(T21<date(2017,1,1),T21,"01/01/2017")
DATE() is year, month, day
Also, you may want to use DATEVALUE() on the FALSE value to force the returned item to a date:
=if(T21<date(2017,1,1),T21,DATEVALUE("01/01/2017"))
"01.01.2017" is not a valid date in Google docs. You need to change . to /.
=DATEVALUE(SUBSTITUTE(T21,".","/"))
=IF(DATEVALUE(SUBSTITUTE(T21,".","/"))<DATEVALUE(date(2017,1,1)),T21,"01/01/2017")

How to check if today's month date is greater than or less than a decimal number?

I have a column with month day numbers, so 20 means the 20th of the month.
I want to know how to check if a value in this column, say 20 is more than or less than today's month day.
I would use conditional formatting to color the cell in red if that day had not passed already.
What I tried to do was set a cell with today's date:
=TODAY()
Then based on this calculate if the month day was less than or greater by using this:
=DATEDIF(F2, "MD")
I was hoping this wold return a number which I could then do a compare with but this is wrong and I am not sure if what I want to do is even possible.
I have read through the documentation and Stackoverflow but I cannot find any close examples.
Thank you.
If you want to check the day of the month you need to extract exactly that.
If your date is in Cell A1 and your threshold (20) in A2 the conditional formatting formula to check if the date has not passed yet would then go:
=DAY(A1) < A2

Store date with optional month / day

I want to store date in my Postgres database.
The only problem is that this date can have optional day or even month.
Example:
User provides time period when he was employed - not necessary full date (day + month + year), but only start year and end year.
However there are users, who worked only from may to october in the same year so month have to be provided too.
How to handle this kind of optional date parts?
Use a proper date type anyway. Do not store text or multiple columns. That would be more expensive and less reliable.
Use the function to_date(), which is fit to deal with your requirements out of the box. For instance, if you call it with a pattern 'YYYYMMDD' and the actual string is missing characters for day, or month and day, it defaults to the first month / day of the year / month:
db=# SELECT to_date('2001', 'YYYYMMDD');
to_date
------------
2001-01-01
db=# SELECT to_date('200103', 'YYYYMMDD');
to_date
------------
2001-03-01
You could store a precision flag indicating year / month / day in addition if you need that.
While the accepted answer is a good one, there is another alternative.
ISO 8601
The ISO 8601 standard defines sensible formats for textual representations of various kinds of date-time values.
A year is represented in the obvious manner, a four-digit number: 2014
A year-month is represented with a required hyphen: 2014-01Note that in other ISO 8601 formats, the hyphen is optional. But not for year month, to avoid ambiguity.
A full date is similar: 2014-08-21 or without optional hyphens: 20140821. I recommend keeping the hyphens.
So you could store the values as text. The length of text would tell you whether it is year-only, year-month, or date.

Resources