Home > Net >  In Google sheets, can a QUERY statement determine the oldest date in a column, add 6 months to it ,
In Google sheets, can a QUERY statement determine the oldest date in a column, add 6 months to it ,

Time:12-18

Currently, I am having to query the entire set, jot down the oldest date, and then add a GTE (>=) and a LTE (<=) back into the query statement to limit the results to 6 months, like this:

=QUERY(RawData!A1:D, "SELECT * WHERE A = 'N502SY' and C >= date '2020-03-20' and C <= date '2020-09-20' ORDER BY C ASC")

Ideally, the query statement would determine ON ITS OWN what the oldest date is and then display all rows found with that date PLUS all rows that have a date within a 6-month period (from the oldest date).

Have done a ton of google searching to find an answer but have come to the conclusion that QUERY statements may not be as robust as I am hoping for. Here is the URL (kindly do not change the raw date):

enter image description here

CodePudding user response:

You can try with FILTER and SORT too:

=SORT(FILTER(A1:D,A:A="N502SY",C:C>=EDATE(MAX(C:C),-6)),3,1)
  • Related