Skip to Content
0
Former Member
May 18, 2016 at 01:17 PM

Evaluate date field, use only if not null/empty in query.

1993 Views

We have this query:

select LastReqTime,

BlockedOn,

UncommitOps

FROM sa_conn_info()

WHERE LastReqTime < DATEADD(mi,-60,GETDATE()) AND BlockedON > 0 AND UncommitOps = 0

Normal data example would be 2016-05-17 17:03:42.721 in LastReqTime.

As one can see by my code, I'm checking for LastReqTime older than 60 minutes. If the field is null or empty, the code errors. I need an IF or CASE or even a nested select statement that will allow me to check the LastReqTime for notnull, I would guess !='' OR perhaps a field length greater than 0. I was hoping for a valid date/time evaluation, but apparently it's quite a bit more complicated than that Since I need results fast I figured I'd ask the experts here (of course it would be here). Thanks in advance.