'Access 2016 with SQL Group by with date range

I have a database with a lot of records. User is inserted using Access 2016.

ex: 
| PADID | Date  | numbers | UserID1 | UserID2 |
| ----- | ----- | ------- | ------- | ------- |
| 123456 | 03/01/22 | 0.0111 | 123  | 142 |
| 134567 | 03/01/22 | 0.035  |  123 | 146 |
| 235867 | 03/09/22 | 0.014  |  142 | 123 |
| 123584 | 04/12/22 | 0.001  |  146 | 123 |

"SELECT DISTINCT DATE, SUM(NUMBERS) AS SUMNUM, USERID1, USERID2 FROM TABLE1 " & _
"WHERE ((USERID1 = " & USERIDNUMBER & ") OR (USERID2 = " & USERIDNUMBER & ")) " & _
"AND DATE >= " & StartDate & " and Date <= " & EndDate & " " & _
"GROUP BY DATE, USERID1, USERID2 " & _
"ORDER BY DATE;"

USERIDNUMBER = 123
STARTDATE = 03/01/22
ENDDATE = 03/30/22
RESULTS IN:

| Date | numbers |
| -------- | -------------- |
| 03/01/22| 0.0461 |
| 03/09/22| 0.014|          
| 04/12/22|0.001|

This returns the output I want, with the exception that it shows everything instead of just the dates that fall between startdate and enddate.

I would like to get the values that fall between startdate and enddate.



Solution 1:[1]

well looks like a few cups of coffee and just dumb luck and i figured it out. 2 days of looking at this simple string and it just came to me

"SELECT DISTINCT DATE, SUM(NUMBERS) AS SUMNUM, USERID1, USERID2 FROM TABLE1 " & _
"WHERE ((USERID1 = " & USERIDNUMBER & ") OR (USERID2 = " & USERIDNUMBER & ")) " & _
"AND DATE BETWEEN '" & StartDate & "' and '" & EndDate & "' " & _
"GROUP BY DATE, USERID1, USERID2 " & _
"ORDER BY DATE;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matthew Throesch