If you’re getting SQL Server error msg 9837 that tells you “The date value is less than the minimum date value allowed for the data type…”, it sounds like you’re using the DATETRUNC()
function with the week
date part on a date that would cause the result to backtrack to a date that’s earlier than the date type supports.
This is a rare error that only occurs when using the week
date part with the DATETRUNC()
function on a very small number of early dates.
One way to deal with this error would be to use iso_week
instead of week
, if that’s suitable for your particular situation.