I think the problem stem from the the field not containg a date correctly.


I was thinking about adding something to the effect of a CASE statement using the ISDATE function to check if it is a date. But the following does not work either


select personid from persondemographic(nolock)
where demographicgroupid =3
and demographicitemid = 4
CASE
WHEN isdate(demographicvaluedesc) =1 THEN  cast(demographicvaluedesc as datetime) > getdate()
ELSE
END

-----Original Message-----
From: Philip Arnold [mailto:[EMAIL PROTECTED]
Sent: Friday, March 26, 2004 12:27 PM
To: CF-Talk
Subject: RE: SQL problem/Question

> From: Eric Creese
>
> How come when I issue this statement
>
> select * from persondemographic(nolock)
> where demographicgroupid =3
> and demographicitemid = 4
> and cast(demographicvaluedesc as datetime) > getdate()-1
>
> I get a result set, but all the fields and when I issue this statement
>
> select personid from persondemographic(nolock)
> where demographicgroupid =3
> and demographicitemid = 4
> and cast(demographicvaluedesc as datetime) > getdate()-1
>
> I get this error
> Server: Msg 241, Level 16, State 1, Line 1
> Syntax error converting datetime from character string.

You can't just take a number away from a date

1 what? 1 nanosecond? 1 year?

Use DateAdd() and ti should fix it

Also, check the values in your "demographicvaluedesc" field - if any of
them aren't able to be converted to a date, then the whole thing will
fail
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to