0 - 2 of 2 tags for select statement

This has been working for weeks, until today. I wasn't sure what broke my script until I tried dropping the date requirement and then it started working perfectly. 6 month ago is February 30, I am guessing, by TD logic, which doesn't exist.
Any general solutions?

Hi Guys,
I need to create a function that reads its result from a table, so I need to use a SELECT statement to read the output. Something like that: