I was recently told that using the BETWEEN method in SQL is somewhat unreliable, and therefore I have to use DATEDIFF() . However, another programmer told me that this is not so, and the BETWEEN method works brilliantly in all cases, as long as the date is formatted correctly.
Please, can someone solve this discussion by indicating which method is better and why?
Currently, my SQL date range is as follows:
DATEDIFF(d,'01-Jan-1970',SIH.[Something_Date]) >= 0 AND DATEDIFF(d,'01-Jan-2013',SIH.[Something_Date]) <= 0
However, I would rather write it like this if I were sure that it was reliable:
SIH.[Something_Date] BETWEEN '01-Jan-1970' AND '01-Jan-2013'
In this particular case, I am using MsSQL, however I have tagged MySQL as I would like to know if this is applicable here as well
source share