Within the Test db there are only 15 row and as the query sit now with out
"Arnie Rowland" <arnie@1568.com> wrote in message
news:eNBN3Mm4GHA.2348@TK2MSFTNGP06.phx.gbl...
>I have to agree with Jens (above). Verify that all rows have valid datetime
>values in the v_GS_Warranty_Summary0.HWEndDate0 field.
>
> Looking just three lines above the 'offending' line, I notice that you are
> testing for a value of 'n/a'. That cannot evaluate to a valid datetime
> value, and the datediff function will fail. So if you do indeed have the
> value 'n/a' stored in the column, you will have to eliminate those
> non-conforming columns first.
>
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
>
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
>
> "Garth" <Spam@Spam.ca> wrote in message
> news:u18n2Fm4GHA.1196@TK2MSFTNGP02.phx.gbl...
>> The real column name is HWEndDate0
>>
>> declare @now as datetime
>> set @now = convert(smalldatetime,Getdate(),120)
>>
>> select
>> v_GS_COMPUTER_SYSTEM.name0 as 'PC Name',
>> v_GS_COMPUTER_SYSTEM.username0 as 'User id',
>> v_GS_Warranty_Summary0.manufacture0 as 'Manufacturer',
>> v_GS_Warranty_Summary0.Model0 as 'Model',
>> convert(smalldatetime,v_GS_Warranty_Summary0.HWEndDate0,120) as date,
>> @now as 'now'
>> from
>> v_GS_Warranty_Summary0 v_GS_Warranty_Summary0,
>> v_GS_COMPUTER_SYSTEM v_GS_COMPUTER_SYSTEM
>> where
>> v_GS_Warranty_Summary0.ResourceID = v_GS_COMPUTER_SYSTEM.ResourceID
>> and v_GS_Warranty_Summary0.ResourceID not in(select
>> v_GS_Warranty_Summary0.ResourceID from v_GS_Warranty_Summary0 where
>> v_GS_Warranty_Summary0.HWEndDate0 in ('n/a','Not Applicable'))
>> and v_GS_Warranty_Summary0.HWEndDate0 is not NULL
>> and isdate(v_GS_Warranty_Summary0.HWEndDate0) = 1
>> and DATEDIFF(dd, getdate(),v_GS_Warranty_Summary0.HWEndDate0) < 0
>>
>>
>> Here is the full blown query.
>>
>> If I comment out the last line everything work perfectly however with the
>> line in I get an error.
>>
>>
>>
>> "Arnie Rowland" <arnie@1568.com> wrote in message
>> news:eXMNiyk4GHA.1244@TK2MSFTNGP03.phx.gbl...
>>> In the future, please don't use reserved words for table and column
>>> names. [Date] is a reserved word. If you 'inherit' situations where
>>> reserved words have been used and you are stuck with them, you MUST
>>> remember to ALWAYS use square brackets [] on each side of the reserved
>>> word.
>>>
>>> Also, I noticed that in your WHERE clause below, that you have [Date0]
>>> as the column name? From your earlier message, it appeared as [Date].
>>>
>>> Is it [Date] or [Date0]?
>>>
>>> (Using [Date0] will cause the error message that you are receiving.)
>>>
>>> --
>>> Arnie Rowland, Ph.D.
>>> Westwood Consulting, Inc
>>>
>>> Most good judgment comes from experience.
>>> Most experience comes from bad judgment.
>>> - Anonymous
>>>
>>>
>>> "Garth" <Spam@Spam.ca> wrote in message
>>> news:Oth9TFk4GHA.1544@TK2MSFTNGP04.phx.gbl...
>>>> Un-fortunately that is not working, when I use "and DATEDIFF(dd,
>>>> getdate(), tablename.Date0) < 0" I still get
>>>>
>>>>
>>>> Server: Msg 241, Level 16, State 1, Line 6
>>>>
>>>> Syntax error converting datetime from character string.
>>>>
>>>>
>>>>
>>>> When it is converting from a string how does it know that the date is
>>>> formatted as yyyy-mm-dd or how can I force it to know that the string
>>>> date are yyyy-mm-dd?
>>>>
>>>>
>>>>
>>>>
>>>> "Jens" <Jens@sqlserver2005.de> wrote in message
>>>> news:1159365737.529867.165540@k70g2000cwa.googlegroups.com...
>>>>> Hi,
>>>>>
>>>>> simply use the datediff funtion for that:
>>>>> DATEDIFF(dd,GETDATE(),'2006-02-20')
>>>>>
>>>>> HTH, Jens K. Suessmeyer.
>>>>>
>>>>> ---
>>>>>
http://www.sqlserver2005.de >>>>> ---
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>