I have a query that looks like this
SELECT * from myTable WHERE Date BETWEEN @Sunday AND @Saturday
I want this query to include elements that occured on sunday and on saturday too. I know I could just change the values to Between @Saturday AND @Sunday but let’s say I don’t want to change the date calculation algorithm is there a way to include both dates ?
Never use
BETWEENfor date/time range queries. If you want anything that happened from Sunday at midnight to Saturday at 23:59:59.9999999, the safest way using any date/time data type is:Please give these two articles a read:
What do BETWEEN and the devil have in common?
Bad habits to kick : mis-handling date / range queries