Add a TRY_DATEADD function to handle overflows

%3CLINGO-SUB%20id%3D%22lingo-sub-2666283%22%20slang%3D%22en-US%22%3EAdd%20a%20TRY_DATEADD%20function%20to%20handle%20overflows%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2666283%22%20slang%3D%22en-US%22%3E%3CP%3EI%20would%20like%20to%20return%20a%20default%20value%20if%20DATEADD%20overflows.%20Currently%2C%20the%20only%20way%20to%20handle%20DATEADD%20overflows%2Funderflows%20is%20with%20a%20TRY%2FCATCH%20block.%20TRY%2FCATCH%20is%20not%20allowed%20in%20user-defined%20functions%2C%20so%20if%20there%20is%20an%20overflow%2C%20I%20have%20to%20resort%20to%20a%20cursor%20to%20find%20the%20rows%20that%20overflowed%20and%20replace%20DATEADD%20with%20a%20default%20value.%20If%20there%20was%20a%20TRY_DATEADD%20function%2C%20this%20could%20be%20done%20with%20a%20set-based%20approach%20that%20would%20require%20less%20code%20and%20perform%20better.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Regular Visitor

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