Sheets Get value from the earliest/latest date and time from column - google-sheets

I have a table that is filled with dates and values.
I have 2 columns. One with date in format YYYY-MM-DD HH:MM:SS. Another with percentage number.
I need to automatically calculate the difference between the last value (percentage number) in month (date and time, for example 2021-03-11 22:55:00) and first value (percentage number) in month (date and time, for example 2021-03-10 03:04:00).
Also I need to automatically calculate the difference between the first value (percentage number) in current month (date and time, for example 2021-03-11 22:55:00) and first value (percentage number) in previous month (date and time, for example 2021-03-10 03:04:00).
He is the table
https://docs.google.com/spreadsheets/d/1_zxoGv02ki1qYdngMP28QGc0VxA3BfNzn7vyX1yA0q8/edit?usp=sharing
With red I highlighted desired values. With yellow needed result.
Last Date - First date
First Date - First date

You can use a mix of FILTER(), MAX(), MIN(), and EDATE() in this case.
For Last Date - First Date, you can try using this formula:
=FILTER(B:B, A:A=MAX(A:A)) - FILTER(B:B, A:A=MIN(A:A))
As for the First Date - First Date, you can try using this one. This works on the sample sheet that you've provided:
=MIN(FILTER(B:B, A:A > EDATE(MIN(A:A), +1))) - FILTER(B:B, A:A=MIN(A:A))

Related

Switch date and month google sheet

I have a data column which date in this format 05/12/2021 = dd/mm/yyyy but google sheet see it as 05/12/2021 = mm/dd/yyyy, how can I use a formula to switch the day and month around and display as 5/12/2021 = d/mm/yyyy. It has to be done on a formula level as there are many other dates column that has the format and information right.
Formula tried
=TEXT(A3:A,"d/mm/yyyy")
If the date is entered correctly, you should be able to format it by going to the 'Format' menu.
However, if you need to transpose the formatted day and month using formula, then try this in row 3 (any column but A):
=arrayformula(datevalue(regexreplace(to_text(A3:A),"(.|..)[\/\-\.](.|..)[\/\-\.](.*)","$2\/$1\/$3")))

Google Sheets: Show upcoming dates for certain day of the week

I am working on a weekly budget sheet and I would like to show dates for each upcoming friday for the current month. How can I do this?
You may apply sequence formula to generate a serial of number for each Friday day and to return all the subsequence date for your budgeting:
=arrayformula(date(year(A1),month(A1),
SEQUENCE(ROUNDUP(DATEDIF(A1,EOMONTH(A1,0),"D")/7,0)-1,1,DAY(A1)+7,7)))
So how does it work:
date(year, month, day)
Return a new date from the number given by formula
ROUNDUP(DATEDIF(A1,EOMONTH(A1,0),"D")/7,0)-1
To calculate to total number of remaining week between the current date and end of the month, you can use Rounddown but need take remove minus 1 at the back
DAY(A1)+7
Return the day of next Friday based on the current Friday date
SEQUENCE(row,column,start,steps)
The row value will determine how many counts of value to be populated, which is the number of week from above formula, start will be start date of next Friday, and step is every 7 days
Sample Sheet:
Remark:
You can add the if statement to return blank when the number of remaining week is 0 to prevent the formula return error
if((ROUNDUP(DATEDIF(A1,EOMONTH(A1,0),"D")/7,0)-1)=0,""

get the next date based on frequency set using google sheet formula

I need to display the upcomind date based on the start date and frequency set.
I have tried with
=TODAY() + MOD(TODAY() - C2, F2)
Here is the sheet
Could try:
G2 + F$2-MOD(G2 - C$2, F$2)
where G2 is today's date
Answer:
The upcoming date is given by:
=((((((C2-DATE(1970,1,1))*86400)+(((D2-DATE(1970,1,1))*86400)-((C2-DATE(1970,1,1))*86400))/H2)/60)/60)/24)+DATE(1970,1,1)
This is equivalent to:
(end date) - (start date)
(start date) + ___________________________
(frequency)
Where each date is converted to a unix timestamp for calculation and converted back to date format for display.
Remember that frequency will have to be decremented when each upcoming date passes in order to update the formula to the new upcoming date.
References:
DATE - Docs Editors Help
Unix Time - Wikipedia

How to auto create a Month calendar in google sheets. Where first day of the month start in the colum of the (name)day

I want to create a calendar like in the second image. But I can not figure out how to start the first column is a monday. So I fill it by 'hand' like in the first image.
I tried to create it automatic. Starting with the first day of the month and add one day the next columns like in the second picture:
How I want it to look like:
How it is currently looking:
Google sheets example
I was solving the same problem for my bussiness, and I think I got the answer.
Your first task is to determine the first "calendar monday" of the month.
First, build the first day of the corresponding month:
[B2] =DATE(YEAR(A1); MONTH(A1); 1)
Then, get the WEEKDAY of the corresponding first day. The second argument represents what day your week starts with:
If type is 1, days are counted from Sunday and the value of Sunday is 1, therefore the value of Saturday is 7.
If type is 2, days are counted from Monday and the value of Monday is 1, therefore the value of Sunday is 7.
If type is 3, days are counted from Monday and the value of Monday is 0, therefore the value of Sunday is 6.
In my case, we count the week starting from Monday. This means when the first day of the month lands on Monday, the return value will be 0.
[C2] =WEEKDAY(B2; 3)
The number you get represents how many days you need to substract from the initial date to get the first "calendar monday" of the month:
[D2] =B2 - C2
This date is what you are looking for. The final formula:
[A3] =DATE(YEAR(A1); MONTH(A1); 1) - WEEKDAY(DATE(YEAR(A1); MONTH(A1); 1); 3)
The rest of the days, simply add 1 to each preceding date.
[A4] =A3 + 1
[A5] =A4 + 1
And so on.
Secondly, set the Number Format on the calendar cells to just show the day.
Format -> Number -> More Formats -> More Date and Time Formats.
Select just the day from the drop down.
Finally, use conditional formatting to "hide" the values that don't match the initial date
Use a custom formula for the formatting, as follows:
=MONTH(A3) <> MONTH(A1)
Apply to the calendar range. This will format dates that don't belong to the current date, so make sure to paint that white.
And that's about it. Good luck!

How to write a query in Google Spreadsheet that returns date >= today?

I am writing the following =filter formula in Google spreadsheet:
=FILTER('Tab'!6:1963, ‘Tab’!E6:E1963 = "Major", ’Tab’!D6:D1963 > NOW())
Column D are dates and I am interested in including today. For instance today is the 7/19 and I would like to have the data that includes 7/19. My current formula returns values only from tomorrow (7/20). I tried the now()-1 but returned an #VALUE!.
Any help?
NOW() returns a datetime object (which includes the time). If you are comparing with a date, NOW() will (almost :) ) always be greater than the date alone (which would have a time component of 12:00 A.M., which is essentially 0).
Try using TODAY() to get the date only (adding/subtracting 1 will use tomorrow/yesterday, respectively).

Resources