I am trying to query a google sheet by date. I have done some research and learned I need to convert to TEXT format so that I can run the comparison, but I am not able to get the syntax correctly:
=query('SheetName'!$A2:$S, "select A Where O=date'"&TEXT(B2,"yyyy-mm-dd")&)
Could you give me some guidance?
Some more info: in my query, B2 is a valid date in date format. Column O has some cells that are text strings and others that are valid dates; I have set the format of the entire column to "Date".
Here is a link to a simple example, feel free to play around with the query: https://docs.google.com/spreadsheets/d/1O4ms9ufvZ_CRLl_LG45hksjRoOJtv0XexbfjCLqFW4I/edit?usp=sharing
See if this works?
=filter('SheetName'!A3:A, 'SheetName'!O3:O=B2)
correct syntax should be:
=ARRAYFORMULA(QUERY(TO_TEXT(SheetName!$A2:$S),
"select Col16 where Col15 = '"&TO_TEXT(DATEVALUE(B2))&"'"))
Related
Google spreadsheet sample: https://docs.google.com/spreadsheets/d/1MdRjm5QmKY_vaah9c3GrvH6dDOBCQX_zvCubvN0akmk/edit?usp=sharing
Im trying to get the sum of all values for each ID. The values im trying to add up are found in the Source tab while the calculations are done in the Output. My desired values are based on 2 things: ID and Date. The Id is supposed to match and the Date is supposed to be February. I tried first just using a sumif with just matching ID and it worked using this formula: =ARRAYFORMULA(IF(A2:A="",, SUMIF(Source!A:A,A2:A,Source!B:B)))
But when I add the 2nd critera and use a sumifs function, it only outputs for the first id. Here is the sumifs formula I used: =ARRAYFORMULA(SUMIFS(Source!B2:B,Source!A2:A,A2:A,Source!C2:C,">="&DATE(2021,2,1),Source!C2:C,"<="&DATE(2021,2,28)))
I tried using query as some of the answers I found online suggested to use it but it also outputs the first data only, here is the query formula I used =ARRAYFORMULA(QUERY(Source!A2:C,"select sum(B) where A = '"&Output!A2:A&"' and C >= date '"&TEXT(DATEVALUE("2/1/2021"),"yyyy-mm-dd")&"' and C <= date '"&TEXT(DATEVALUE("2/28/2021"),"yyyy-mm-dd")&"' label sum(B) '' "))
I know this is possible by making a temporary query/filter where you only include desired dates and from there I can use SUMIF, but I will be needing to make a monthly total and making 12 of these calculated temporary filters/query would take up a lot of space since we have a lot of data so I want to avoid this option if possible. Is there a better fix to this situation?
Solved by Astrotia - =arrayformula(sumif(I3:I20&month(K3:K20), A2:A6&2, J3:J20))
I'm very new to programming so I'm not sure how to phrase this but in google sheets, I'm having a problem:
when filtering results using =IFERROR(FILTER('Segment Management'!B:B,'Segment Management'!A:A=B5)), it works perfectly fine with letters and numbers but when there's a date in Segment Management cell B5 it instead of saying the date (in this case 15/3/2020) it outputs "43906". Could I get some help to explain why it says this number instead of the date?
Date is considered as plain number in google sheets that's the reason you get numbers instead of date you can either do either of one
Select the column where you have put formula & in menu Format> Number> and select date formatting
OR
use this formula =ARRAYFORMULA(TEXT(FILTER('Segment Management'!B:B,'Segment Management'!A:A=B5),"DD/MM/YYYY"))
I have a Google Sheet with some stock information.
I'm using the formula GOOGLEFINANCE($B2, "price",TODAY()-15) to retrieve historical information about a stock (symbol named in $B2).
That returns a 2x2 table:
Date Close
8/25/2017 17:36:00 7.46
I only want the 7.46:
Using =FILTER(GOOGLEFINANCE($B2, "price",TODAY()-15),{FALSE; TRUE}) I get:
8/25/2017 17:36:00 7.46
I can't see to be able to nest FILTER twice.
I checked the documentation. Other than say that I should not use FILTER to filter columns and rows in the same call, I didn't get much out of it.
I gather a lot of stock information and always use index to get the stock price.
=index(GOOGLEFINANCE($B2, "price",TODAY()-15),2,2)
If you want the date use this. Be sure to format the cell as date or date/time.
=index(GOOGLEFINANCE($B2, "price",TODAY()-15),2,1)
For 2 filters try:
=FILTER(FILTER(GOOGLEFINANCE($B2, "price",TODAY()-15),{false;true}),{false,true})
I prefer query in this case:
=QUERY(GOOGLEFINANCE($B2, "price",TODAY()-15),"select Col2 label Col2 ''")
Also please try this formulas separately:
={false;true}
={false,true}
and see the result.
I'm trying to return the last time log from a list in Google spreadsheet using Google Sheet query max() function.
=query(A:A, "select max(A)",1)
The time log data (column A) is in text format dd/mm/yyyy hh:mm:ss, which is imported to google sheet using importdata function.
The above query is not returning the correct result. I think it's because the source of data is in text format.
e.g. The above query will return 9/9/2017 23:58:00 while the normal =max(A:A) function returns 12/9/2017 19:12:00.
Is it possible to reformat the text to datetime format within the query clause?
The data sample is from here:
https://docs.google.com/spreadsheets/d/1EwT5ZvCCLLorWomaeJFMhAziWnhW9zTwco9dfwoXJJ4/edit#gid=0
It's possible, for example:
=query(ArrayFormula(1*filter(A:A,NOT(ISBLANK(A:A)))), "select max(Col1)",0)
(and probably something a bit simpler!) but the obvious preferred option is to treat date/times as date/times, not text.
I have a datestamp in this format on A2:
18.11.2015 15:37:13
How can I split this into date and time so that I have date in A3 and time in A4?
I want to do this because datestamp does not sort properly as a number.
I found several answers to this question with various answers but none of them worked for me.
Wouldn't a simple split() be enough ? In B2:
=split(A2, " ")
Alternatively, in B2:
={INT(A2), timevalue(A2)}
Make sure to format col B as DATE and col C as TIME and see if that works?
To get the date and time in those cells you can do the following:
A3: =DATE(MID(A2,7,4),MID(A2,4,2),LEFT(A2,2))
A4: =TIMEVALUE(RIGHT(A2,8))
It's essentially extracting the essential parts for year/month/day from the string in A2 to get the needed order for date. The time is already properly formatted and can be used with Timevalue, we just need to extract the substring.
The date and time values can then be formatted in any way you want them.