Error with Datetime in Query
Posted on 2011-03-14
I have the following query.
wi.ServiceTag0 [Service Tag],
wi.shipdate0 [Ship Date],
wi.Startdate0 [Warranty Start Date],
wi.Enddate0 [Warranty End Date],
DateDiff("d",wi.Enddate0,GETDATE())[Warranty Days Remaining],
wi.WarrantyExtension0 [Warranty Extension],
wi.SystemType0 [System Type],
wi.datescriptran0 [Timestamp data gathered],
wi.Description0 as [Description]
from v_R_System as [SYS]
join v_gs_Warranty_Info0 as [WI] on sys.resourceid=wi.resourceid
order by sys.netbios_name0
The warranty end date is in the format MM/DD/YYYY except for a few fields where it could not collect the data, those fields show up as "--"
I'm sure I need a case statement in there where I bolded the line above to resolve the error, but I can't figure it out. Here's the error.
Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.