dateOf: improved support for dates before 1753 in SQL Server
Description
EQL's function dateOf gets converted to DATEADD(dd, DATEDIFF(dd, 0, <column>), 0). Due to the fact that 0 is considered by SQL Server to be of type datetime, every argument is treated as datetime. This leads to runtime errors in case the underlying data of type datetime2 includes values before 1753-01-01 (the minimum value for type datetime).
The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
-
[ ] 1. Value
CAST('0001-01-01' AS datetime2), which represents the minimum value fordatetime2, should be used inDateOf3instead of0,:DATEADD(dd, DATEDIFF(dd, CAST('0001-01-01' AS datetime2), <column>), CAST('0001-01-01' AS datetime2)) -
[ ] 2. Need to inspect other date-rated EQL functions to make sure they work correctly with dates before
1753-01-01.
Note: may be of interest https://stackoverflow.com/questions/3310569/what-is-the-significance-of-1-1-1753-in-sql-server
Expected outcome
Extended range of supported date values.