Query in google sheets first result is not a date - google-sheets

I'm trying to query a bunch of dates and it generally works fine, except for the first result. This does not get recognized as a date.
I query the date with =query(A1:B50;"SELECT A";1) where dates are in column A.
Subsequently I use the output to create events in Google calendar, except the first result of the query doesn't get recognized as a date.
Anything I can do about that?
Thanks!

If cell A1 contains a date and not a column heading, try:
=query(A1:B50;"SELECT A";0)
However, It's not clear why you're using QUERY and {A1:A} may work just fine instead.

Related

Google Sheets – Query for a date returns no values

​​I'm trying to filter a list from another sheet by the dates of the entries and simply doesn't work:
=QUERY(Import!A:Z;"select A,T where T >= date '2021-08-27'";0)
​When I remove the date part it works fine, as expexted for filtering by text. I need the ability to sort by exact dates though, because I would like to add some more complex filters. When I set the last part of the function to a 0 instead of a 1 it shows only the first entry.
The source column is set to the correct date format. The data is pulled from another document using the IMPORTRANGE()​ function (I don't seee how this should make any difference though).
I feel like I'm misssing something simple here and would be glad if someone can point me in the right direction!
Check your date column if all cells are formatted as date. I had missing values as "='---" and the query filtering by date returned nothing. Changing the missing values to "=NA()" did the job.
Try this:
=QUERY(Import!A:Z;"select A,T where T >= date '"&TEXT("2021-08-27";"yyyy-mm-dd")&"'")

regexmatch doesn't seem to work with minifs in Google Sheets

I'm trying to find the min date for sub-tasks that are related to the same Task ID.
Because I want to leave the task min date cell blank if none of the sub-tasks have a date entered, I use the following formula:
=if(SUMPRODUCT(regexmatch($A18:$A,"^Sub-Task "&$B16&".[0-9]"),$F18:$F=$F16,G18:G<>"")<>0,minifs(G18:G,$A18:$A,regexmatch($A18:$A,"^Sub-Task "&$B16&".[0-9]"),$F18:$F,$F16,G18:G,"<>"),"")
This breaks downs as follows:
In the SUMPRODUCT function
I use regexmatch($A18:$A,"^Sub-Task "&$B16&".[0-9]*") to check that I only look at sub-tasks that have the same ID as the specific task "B16"
I use $F18:$F=$F16 to check that I only look for "Planned" dates, which is in "F16" instead of "Actual" dates
I use G18:G<>"" to check that I only look for date cells that aren't empty
If the sumproduct results in something, I then use the minifs() function to find the min value of the result.
IF the sumproduct results in nothing, I enter blank "" in the cell
The sumproduct seems to work perfectly well and gives me the results that I expect when I change values around, but the minifs function doesn't seem to work with regexmatch()
Is there a different syntax that has to be used in minifs functions?
try:
REGEXMATCH(A18:A&"", "^Sub-Task "&B16&".*")
inserting numeric value in regex will cause VALUE error
Figured it out, minifs can take regex directly, but only simple ones; it doesn't like characters like "^", and I was able to work around it for my needs.

How to find earlier date in google spreadsheets?

in Google Spreadsheets I have a column A with dates and column B with specific values corresponding these dates:
A
B
10-Jan
51.1
11-Jan
49.2
14-Jan
50.3
If I find via VLOOKUP function the value of 11-Jan, it will work and show 49.2.
Off cause it won't work if I try to find a value of 13-Jan since it is absent from the list of dates. However, if the date is absent in column A I want to get the value of earlier date which is in the list (i.e. I want to get 49.2 corresponding to 11-Jan, if I use 13-Jan as the query for finding the value).
Maybe this type of search can be realized by using INDIRECT function, but I can't figure out the formula.
How do realize this?
Your problem can be solved by using vlookup only but with different parameter, if you indicate True for the last parameter, it mean the formula will try to return the closer match if it cannot found any result.
=arrayformula(VLOOKUP(E1:E5,A:B,2,True))

Why does a different result show up when filtering a date in google sheets?

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"))

Compare dates in WHERE request within QUERY in GoogleSheets

I'm trying to query a range that returns only rows where the date in Column S is older than the date in Column D
All dates in the sheet are already formatted yyyy-mm-dd but I can't seem to find any suggestions on how to use WHERE with a range of dates, rather than either a single date or a specific cell.
=QUERY(Sheet1!A2:W11536,"select A,B,C,D,E,F,G,H,I,J,K where date '"&text(Sheet1!D2:D,"yyyy-mm-dd")&"' > date'"&text(Sheet1!S2:S,"yyyy-mm-dd")&"'")
This is giving me an N/A error: "Query completed with an empty output."
When I make it < rather than > it populates without error, though it's not showing the desired results. There should be valid data for >.
Thanks!
I think this is enough when you're comparing two columns
=query(A:H,"select A,B,C,D,E,F,G,H where C>H")
(although I couldn't find any rows that satisfied the criteria in your test sheet)
I think what is actually happening is that it is just comparing the first two dates so you either get all of the data or nothing.

Resources