Add a TRY_DATEADD function to handle overflows

Copper Contributor

I would like to return a default value if DATEADD overflows. Currently, the only way to handle DATEADD overflows/underflows is with a TRY/CATCH block. TRY/CATCH is not allowed in user-defined functions, so if there is an overflow, I have to resort to a cursor to find the rows that overflowed and replace DATEADD with a default value. If there was a TRY_DATEADD function, this could be done with a set-based approach that would require less code and perform better.

0 Replies