I am trying to match a date within a google spreadsheet, but I am new to this, and I could use some help. I have a column that contains a list of birthdays. I have a cell that I am using to reference for the current date by using
=Today()
What I would like to do is compare the month and day, but ignore the year, and return the values in the two adjacent columns. I am using this query to try to get the information.
=QUERY(C2:E430; "select * where C = date '" & text(F2,"yyyy-MM-dd") & "'")
but it always returns an empty output, because the year never matches. How do I get it to ignore the year?
Thank you,
Paul
One way would be to compare the month and day separately (note that the MONTH() spreadsheet function is January = 1, while the month() function in the QUERY select clause is January = 0).
=QUERY(C2:E430;"select * where month(C) = "&(MONTH(F2)-1)&" and day(C) = "&DAY(F2))
Related
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):
https://docs.google.com/spreadsheets/d/17n3PYBrhlbD1RIgToohS3a1QbN5qhrQnREcMAnZdcbY/edit#gid=626607315
your shared sheet has restricted access. so here's a working formula based on rough sample data.
=QUERY(A:D, "SELECT * WHERE A = 'N502SY' and C >= date '"&text(EDATE(MAX(C:C),-6),"yyyy-mm-dd")&"' and C <= date '"&text(MAX(C:C),"yyyy-mm-dd")&"' ORDER BY C ASC")
-
You can try with FILTER and SORT too:
=SORT(FILTER(A1:D,A:A="N502SY",C:C>=EDATE(MAX(C:C),-6)),3,1)
I have a sheet with these columns:
A (Date): Range of dates for the year
B (Amount): An amount for an expense
D (Month): Name of each month in the year (e.g. June, July, etc)
I've tried this as suggested to work in other posts:
=SUMPRODUCT(B:B, ISDATE(A:A)*MONTH(A:A)=MONTH(D3&1))
I get the error Function MONTH parameter 1 expects number values. But 'Date' is a text and cannot be coerced to a number. with this.
If I remove the header, I just get a 0 for the sum for each month, which is incorrect.
How do I get this to work for each month the way my sheet is setup?
What the sheet currently looks like:
https://docs.google.com/spreadsheets/d/1_8DQTa9aXGjvd7twL6RZMcFyqxa4Sg7eVTcD2wDXH2A/edit?usp=sharing
Try this instead. Not sure where you got that other formula:
=SUMPRODUCT(B:B,TEXT(A:A,"mmmm")=D3)
use:
=ARRAYFORMULA(IFNA(VLOOKUP(MONTH(D3:D10&1),
QUERY(A2:B, "select month(A)+1,sum(B) group by month(A)"), 2, )))
Use this
=IF(D3="",,IFERROR(SUM(FILTER($B$2:$B,MONTH($A$2:$A&1)=MONTH(D3&1))),""))
I am trying to query a data set by date and return ID's that are not listed in the queried date range as compared to a master list. I have set up this Google Sheet as an example.
I know and understand how to use the query function to select data by the dates:
=query(Datasheet!$A$2:$B,"Select B where A > date '"&TEXT('Querysheet'!$A$3,"yyyy-mm-dd")&"' and A <= date '"&TEXT('Querysheet'!$B$3,"yyyy-mm-dd")&"' ...")
The part that I am missing is how to compare and return a group of ID's that are missing from the Datasheet compared with the Mastersheet.
use:
=UNIQUE(FILTER(Mastersheet!A2:A, NOT(COUNTIF(UNIQUE(QUERY(Datasheet!A2:B,
"select B
where A > date '"&TEXT(Querysheet!A3, "yyyy-mm-dd")&"'
and A <= date '"&TEXT(Querysheet!B3, "yyyy-mm-dd")&"'")), Mastersheet!A2:A))))
Google Sheets: I checked my column of dates is in DATE format not Automatic.
When I use MONTH in a cell I get the correct month back from that column.
When I do a QUERY such as =query('Main'!A1:M20,"select MONTH(M)",1) I get #VALUE! with the comment:
Unable to parse the Function QUERY for parameter 2: Can't perform the function MONTH on a column that is not a DATE or a DATETIME column
Why does QUERY not see the column as being in DATE format but =MONTH does?
months in a query are numbered and starts from 0, therefore, you will need to add +1 to get the first month and then do a weird logic: "where month1=month2" to get february (month(A)+1=3 for march, month(A)+1=12 for december, etc.)
=QUERY(A1:D10, "select A,B,C,D where month(A)+1=2", 1)
I have a Google spreadsheet containing subscriptions. I need to query that spreadsheet to find out what subscriptions have expired. By searching on the internet, I've found I can query the spreadsheet to find out which subscribers expire after a certain date (2016-02-16 in this example) with this command:
=QUERY(Everyone!$A:$ZZ, "SELECT * WHERE H >= date '2016-02-16' ORDER BY H",-1)
(The expiration date is in column H.)
If the date in question is in a certain cell (E2 in this example) I can do that here too:
=QUERY(Everyone!$A:$ZZ, "SELECT * WHERE H >= date '" & text(E2,"yyyy-MM-dd") & "' ORDER BY H",-1)
I want to know the subscribers that have an expiration date before 2016-02-16. I thought I could just replace the >= with <, but that returns no results. (I know I have dates before 2016.)
So my question:
How to query in a Google spreadsheet to find all dates less than a specified date?
If you look at the bottom of your sheet you will see your data. The issue is with Order By. The null cells in H are sorted first. Add AND H IS NOT NULL and it should solve this.
=QUERY(Everyone!A:J, "SELECT * WHERE H < date '2016-02-16' AND H IS NOT NULL ORDER BY H",-1)
Another option would be to have the exact row numbers Everyone!A1:J16. Then blank cells are not an issue.
Why not just make use of a filter? You can do that such as
=filter(Everyone!$A:$ZZ, H4:H>H3)
//Where H3 is where you put the date of your choice.