Stop counting after today date passed in Google Sheets - google-sheets

I have a column on Google sheets with different dates, I made a dashboard where you can see the upcoming rows with dates within 5 days away from today. It's a box saying "Starting within 5 days" and shows how many rows starts within 5 days. I made it work, the problem is that once we reached the date and passed it, it keeps counting it.
Let's say a row have a cell with the date 2022-10-20 and today is 2022-10-21, that means it already passed the date, so it should stop counting it. It should only count as "1" if the date set in a cell is within 5 days from todays date.
I hope I was clear enough, I use currently =COUNTIF('Under arbete'!C2:C; "<" & today()+5)

your formula
=COUNTIF('Under arbete'!C2:C; "<" & today()+5)
will work only today. every next day it will be offset by +1 day because TODAY will "recalculate" on a daily basis
you can either feed it today's date like:
=COUNTIF('Under arbete'!C2:C; "<"&"2022-10-20"+5)
or try to freeze today's date like:
=COUNTIF('Under arbete'!C2:C; "<"&LAMBDA(x; x)(TODAY()+5))
update:
=COUNTIFS(Kommande!C2:C; ">="&TODAY();
Kommande!C2:C; "<"&TODAY()+10)
for multiple sheets:
=COUNTIFS({Kommande!C2:C; Sheet2!C2:C}; ">="&TODAY();
{Kommande!C2:C; Sheet2!C2:C}; "<"&TODAY()+10)

Related

Parse rows by date filter (Google Tables)

How could I parse rows from my table by dates (logic for example: today is 3 more days until the delivery date) and place it into another sheet?
https://docs.google.com/spreadsheets/d/1TTbIX3qNKXyQAQiJ2EuRNDKWy1YEhLBPzsVw8mxMhKs
I need to run this script automatically (or manually) every day to update a list.
See if this helps
=filter(A2:C; C2:C-today() <=3)

Google Sheets. Automatically change given date plus n days

Good afternoon. I have 2 cells for 2 dates with date format on them and formula =DATE(2022; 1; 19). One cell is a first day of a current week period. Another cell is first day of a next week (=B17+7). I want to make both those cells to automatically change +7 days every week after i enter for example the first current date.
You can use for the first day (monday)
=today()-WEEKDAY(today(),2)+1
One way of solving your need while escaping circular dependency error is to do the following:
Keep cell B17 as is (=B13+7), however, instead of putting a date in cell B13, just put the following formula :
=TODAY()-WEEKDAY(TODAY(),2)+1
The result would be that the 2 cells will always update to the correct dates every time you'd open the spreadsheet.

Update: How to calculate date and time duration into Days in google shee? (excluding Sunday)

I know it's basic but I'm new to this. I just want to know how can I calculate the days duration of the two dates?
For example, I have my start date and time 11/22/2021 15:20:43 and end date and time 11/23/2021 14:51:29 I want to calculate the total days from start to end date and time.
Also, If start date time column is BLANK, return to count of days including date today.
Thank you
All you need to do is use the following formula: '=(C2-A2)'. This will give you the elapsed time between the two cells and display it as hours. You can take this calculation further by adding dates too. This is useful if you have work shifts that go more than 24 hours or that include two days within a single shift.
Assuming start dates in column A and end dates in column B, you can try
={"Duration in Days"; Arrayformula(if(len(A2:A) * len(B2:B), datedif(A2:A, B2:B, "d"),))}
Change ranges to suit and see if that works?
EXAMPLE
REFERENCES:
DATEDIF
there is a DAYS formula exactly for that purpose:
update:
=INDEX(IFERROR(1/(1/DAYS(
REGEXREPLACE(TO_TEXT(B1:B), "(.|..)[\/\-\.](.|..)[\/\-\.](.+) (.*$)", "$2\/$1\/$3"),
REGEXREPLACE(TO_TEXT(A1:A), "(.|..)[\/\-\.](.|..)[\/\-\.](.+) (.*$)", "$2\/$1\/$3")))))
demo sheet

Find if a month belongs to a date range

I have a date range and a corresponding value.
On a the right-hand side of this data table, I want to separate the value monthly.
Available Data
Result Expected
*I have the limits of the date range any row can have. Ex: Mar 1st to Jun 30th.
I can take the number of days in a month and divide the value by that to get the value to fill in.
Problem is automatically deciding the cells which needs to be filled and which has to be marked as 0.
The solution I'm looking for is a formula that can be dragged into many more months.
My approach was to check at each cell if the Month Code("Mar", "Apr", "May"....etc) includes in the date range in A and B columns.
I have searched ways to check this and have failed. Is there a way to check if a month includes within a particular date range?
Or is there any other way I can fill the cells from D2 to G6?
*Actual scenario has more than 4 months and more than 6 Rows of data.
This is a formula giving the exact amounts for first row - not sure if that is what you want though:
=(max(0,min($B2,eomonth(datevalue("1-"&left(D1,3)&"2020"),0)))-max($A2,datevalue("1-"&left(D1,3)&"2020"))+1)*$C2/($B2-$A2+1)
Alternatively
=if(min($B2,eomonth(datevalue("1-"&left(D1,3)&"2020"),0))-max($A2,datevalue("1-"&left(D1,3)&"2020"))>=0 [your formula] ,0)

Google Sheets, increment cell by month

I have a spreadsheet that keeps track of how old accounts are by months.
Is there a way to have Google Sheets auto update a cell on the 1st of each month?
VG: An account is 78 months old and on Sept 1st it turns 79 months. I want to automatically update it on the 1st of the month so I won't have to manually add 1 to every account age cell.
This is for Excel:
If the value is 78 on 25 August 2016 and you want the value to increment of the first of each month, then enter:
=78+MONTH(TODAY())-MONTH(DATEVALUE("8/25/2016"))+12*(YEAR(TODAY())-YEAR(DATEVALUE("8/25/2016")))
Assuming that your dataset does include an account start date in column A, you can calculate how many whole months are between that date and system date today by using:
=DATEDIF(A2,TODAY(),"M")
Tested this in Excel but should work in Google Sheets as well.
You could add another field, and do the calculation from the sheet:
[A1]=<start date>
[A2]=datedif(a1,today(),"M")
Otherwise, you could use a script to do this once a month, but you would need a list of cells somewhere that need to be updated. I would need to see an example of your spreadsheet layout to give you working code.
The process would be to:
set a daily trigger
check for the first of the month
if it is, go and update all the cells
if not, try again tomorrow
This worked out well for me in Google Sheets
DATEDIF("<MY_STARTING_DATE>", today(), "M")
example:
DATEDIF("8/1/2021", today(), "M")

Resources