sql - Adding a value to a 'datetime2' column caused an overflow -


i know why i'm seeing error, it's because of locationdeletiondate '9999-12-31 00:00:00.0000000', , adding 90 days locationdeletiondate (as in query) causes error in title:

...where                 (bpj.jobstatus = 'live')  , (l.locationeffectivedate <= sysdatetime())  , (dateadd(d,90,l.locationdeletiondate) >= sysdatetime())... 

i guess need conditional case in clause ensure date not error if 90 days added? or there more elegant way?

you can use approach solve issue

...where                 (bpj.jobstatus = 'live')  , (l.locationeffectivedate <= sysdatetime())  , (l.locationdeletiondate >= dateadd(d, -90, sysdatetime())... 

in case solve performance issue. predicate becomes sargable.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -