Google Sheets OnEdit Split - google-sheets

I am trying to get the difference in hr/mins between the timestamp of the google form and 8:00 am. Currently, I am using the split function to break the timestamp up and then I am using the diff in time to calculate mins.
https://docs.google.com/spreadsheets/d/1WU_dDxRTX2JWqL1b3e8SHh0GMOfjZ9YT1LV7dADVmz8/edit?usp=sharing
Would anyone be able to make this occur onedit?
Thank you!

try in row 1:
={"Time Late"; INDEX(IFNA(TEXT(REGEXEXTRACT(TO_TEXT(Tardies!A2:A),
" (.*)")-VALUE("8:00"), "h:mm")))}

Related

How to generate sequences in Google Sheets

I'l like to create a sequence of dates using "sequence formula" with a start and end date. I mean, something like this:
start date = 2020-01-01
end date = 2022-12-01
I just also want to bring the first day of the month, like the following example:
2020-01-01
2020-02-01
2020-03-01
......
2022-10-01
2022-11-01
2022-12-01
How can I get this? Is there another way to do it?
Thanks!!!
There are several ways to approach this. Here is one I recommend:
=ArrayFormula(DATE(2020,SEQUENCE(DATEDIF("2020-01-01", "2022-12-01", "m")+1),1))
You'll replace the first 2020 with the year of your starting date and the next two string-dates with your full start and end date. That's it.
Just make sure you leave enough cells open below this formula to accommodate the number of dates you're requiring the formula to output.
Format the output range in the date format you prefer (Format > Number...).
Simple SEQUENCE() should work. Try-
=SEQUENCE((B1-A1)+1,1,A1)

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

Get start date the calendar week

I am using google spreadsheet and have the calendar week and the date.
I want to get for each calendar week the start date of the week.
Find below an example:
Find here my google sheet:
https://docs.google.com/spreadsheets/d/1k-KTzyeVo7tNQOBm42bq0JroF_SugTaLvEGsr5Gt-CA/edit?usp=sharing
Any suggestions how to get the start date of the week?
I appreciate your replies!
Anna, I have set up a new sheet called "Erik Help" and placed the following array formula into cell E5:
=ArrayFormula(IF(E2:2="","",DATE($E$2,1,1)+((E3:3-1)*7)-(WEEKDAY(DATE($E$2,1,1),2)-1)))
Since this is an array formula, it "runs" the entire row. No need to drag across.

Getting data from a google sheet for the previous XX days

I'm logging calls, emails and meetings using Google sheets. I am trying to get a chart of results based on a number of days in the past, 7, 30, last month, current month, etc. I am able to do exactly what I need to do using a fixed date but I can't figure out how to convert that to a date range.
Here is what is working:
={ARRAYFORMULA({UNIQUE(FILTER(CRM!M2:M2510,CRM!N2:N2510>=VALUE("2018-06-01 00:00:00"),CRM!N2:N2510<=VALUE("2018-08-01 23:59:59"),CRM!M2:M2510<>"")),ARRAYFORMULA(COUNTIF(FILTER(CRM!M2:M2510,CRM!N2:N2510>=VALUE("2018-06-01 00:00:00"),CRM!N2:N2510<=VALUE("2018-08-01 23:59:59")),SUBSTITUTE(SUBSTITUTE(UNIQUE(FILTER(CRM!M2:M2510,CRM!N2:N2510>=VALUE("2018-06-01 00:00:00"),CRM!N2:N2510<=VALUE("2018-08-01 23:59:59"),CRM!M2:M2510<>"")),"*","~*"),"?","~?")))})}
I need to change the value from a fixed date to a number of days in the past. What do I need to change in this formula? I tried using TODAY() -7 but I keep getting an error saying that I am missing brackets. When I use (TODAY()-7) I just get an #ERROR.
How can I change the VALUE("fixed date") to VALUE(TODAY -7)?
If your data looks like "2018-06-01 00:00:00".
Then use this conditions for filter to filter the last 7 days:
Arrayformula(datevalue(left(CRM!N2:N2510),10))>=datevalue(today()-7)
,
Arrayformula(datevalue(left(CRM!N2:N2510),10))<=datevalue(today())

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