Error handler required

  • Hi

    I am getting a division by zero error when start date > end date

    Error handler required

    my query is:

    set @datediff1 = (select datediff(day,@start_date1,@end_date1)+1)

  • You can either use try/catch or check with a CASE statement if @datediff1 is 0. If it is, don't do the division and return 0, if it isn't do the division.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply