I have been using SQL for a little while now - having to use Oracle and SQL Server for my work - however, I have just come across something I have not seen before.
After seeing this and doing a bit of research it is said that, in SQL server, the number 0
can be used as the base date, which is:
1900-01-01
so for example:
select DATEDIFF(yy, 0, '2017-12-31')
would return 117
, as 1900-01-01
substitutes the 0
.
My first question is, why is this, considering this is not the minimum date value in SQL (which is the year 1753 I believe)?
My second question is that I came across another piece of SQL which uses the number -1
instead of 0
.
After some testing, I can assume that it is referring to 1899-12-31
. but i cannot be sure as I cannot find anything on this number being used as a date anywhere online. Am I correct?
Thank you for your time.