Sunday, February 19, 2012

Checking for where a datetime column has a null value

I'm trying to filter out sales reps in a resultset that are no longer
with a company, whereas 'Start' is when the salesrep was hired ( a
datetime datatype ) and "Terminated' is when a salesrep was
terminated ( a datetime datatype).
Nulls are allowed in the Terminated column. If that column is null,
then a salesrep still is employed. But when I want to include it in a
where clause:
WHERE (QueriedDate = '20050707') AND (SalesReps.Terminated =
'null'), the syntax is invalid . What function can i use in this sql
string to temporarily change 'Terminated' into something useable so
that I can check for nulls in that column.
Thanks
.NetSportsNULL is not a string, it marks the absence of a value (e.g. UNKNOWN). And
you cannot expect a sane answer from "is terminated = unknown?" Try
AND Terminated IS NULL
"netsports" <ballz2wall@.cox-dot-net.no-spam.invalid> wrote in message
news:EomdnRFBorvv9ZfeRVn_vQ@.giganews.com...
> I'm trying to filter out sales reps in a resultset that are no longer
> with a company, whereas 'Start' is when the salesrep was hired ( a
> datetime datatype ) and "Terminated' is when a salesrep was
> terminated ( a datetime datatype).
> Nulls are allowed in the Terminated column. If that column is null,
> then a salesrep still is employed. But when I want to include it in a
> where clause:
> WHERE (QueriedDate = '20050707') AND (SalesReps.Terminated =
> 'null'), the syntax is invalid . What function can i use in this sql
> string to temporarily change 'Terminated' into something useable so
> that I can check for nulls in that column.
> Thanks
> NetSports
>

No comments:

Post a Comment