- Newest
- Most votes
- Most comments
The error you're encountering is likely due to a type mismatch between the 'month_yr' column in your table and the string literals you're using in the BETWEEN clause. To resolve this issue, you need to ensure that both sides of the comparison are of the same data type.
Assuming that 'month_yr' is a DATE type column, you can modify your query as follows:
SELECT * FROM wslrisrmart.risr_monthly WHERE month_yr BETWEEN DATE '2024-01-01' AND DATE '2024-12-31';
By using the DATE keyword before the string literals, you're explicitly telling the database to treat these strings as date values. This should resolve any type mismatch errors.
If 'month_yr' is stored as a string in your table, you might need to cast it to a DATE type for comparison:
SELECT * FROM wslrisrmart.risr_monthly WHERE CAST(month_yr AS DATE) BETWEEN DATE '2024-01-01' AND DATE '2024-12-31';
Additionally, make sure that the 'month_yr' column in your table actually contains date values for 2024. If the data for 2024 doesn't exist yet, your query will return an empty result set, but it shouldn't throw an error.
If you're still encountering issues, it would be helpful to know the exact error message you're receiving and the data type of the 'month_yr' column in your table.
Sources
TYPE_MISMATCH: line 3:32: Cannot apply operator: date < varchar(10) | AWS re:Post
Relevant content
asked 4 years ago
asked 3 years ago
- AWS OFFICIALUpdated a year ago
