=QUERY(IMPORTRANGE(some_range);"
SELECT Col2,dateDiff(Col20,now())
WHERE Col20 IS NOT NULL AND dateDiff(Col20,now()) <= 30
ORDER BY Col2 ASC
LABEL Col2 'SANITARNA'
";0)
So, i have this query formula which works perfectly for a column that has only dates. However i need to apply it to a column where there are dates and some text values. The problem is when i change the dateDiff column i get an error "Unable to parse query string for Function QUERY parameter 2: Can't perform the function 'dateDiff' on values that are not a Date or a DateTime values"
which makes sense. However, i cant seem to figure out how to incorporate a filter within the dateDiff function to just skip the text values and only output the ones that have dates. My best guess so far is that the filter has to be applied within the dateDiff function in SELECT and not WHERE. I've tried a filter/isnumber formula but get parse error and my brain is fried and can't see the problem.
Test sheet: https://docs.google.com/spreadsheets/d/1thpXBSp-Vt1E5MGaM89Xko6GvekjmzyidO94Sil2AjQ/edit?usp=sharing
CodePudding user response:
See my newly added sheet ("Erik Help"), which contains the following version of your original formula:
=QUERY(FILTER(A:C,ISNUMBER(C:C))," SELECT Col1,dateDiff(Col3,now()) WHERE Col2 IS NOT NULL AND dateDiff(Col3,now()) <= 30 ORDER BY Col1 ASC LABEL Col1 'PRIJAVA DO' ",0)
FILTER
will first filter in only those rows where the value in Col C is a number. And since all dates are numbers as far as Google Sheets is concerned, that will be only your rows with dates in Col C.
NOTE: You currently have no date values in Col C that are less than or equal to 30 days from TODAY() — that is, all of your Col-C dates are in the future — so your table is returning empty (yet without error, because it is working). Because QUERY is acting on a FILTER of the original data and not on the original data itself, all QUERY column references must be in Colx notation, not A-B-C notation.