-1

I have a column of data in the format of yyyy-mm that is VARCHAR(7). Using CONVERT doesn't work and I'm guessing it's because it needs a day in the string (yyyy-mm-dd), but I don't know how to add that to the string. I started with this code:

SELECT * FROM TABLE_X WHERE MONTH BETWEEN ('2022-06','2023-06')
3
  • Date and string functions are very much product-specific. Commented Jul 26, 2023 at 21:53
  • Stu, if I understand you correctly, I should have mentioned that this is in Snowflake. Commented Jul 26, 2023 at 21:59
  • What day do you want to add to the string? Commented Jul 26, 2023 at 22:07

1 Answer 1

1

How about:

SELECT * 
FROM TABLE_X 
WHERE MONTH BETWEEN '2022-06' AND '2023-06'

The comparisons between string will work, as the question states that "column of data in the format of yyyy-mm that is VARCHAR".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.