Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with query when there is bad data
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Application:
Desktop
Divers
Thread ID:
01407429
Message ID:
01407430
Vues:
33
What kind of bad data? The CAST() function wouldn't accept invalid values.

>This stored procedure works great as long as the values in the UpTime1 and DownTime1 are in a valid time format HH:MM. If the're not, it fails to return anything. The DateDiff statement is calculating the number of minutes and this is the line that gives me a hard time if there is any bad data. Those fields are a varchar(5).
>
>We are working on getting the front-end corrected to prevent that, but if I can find a way to make the stored procedure return a zero for the datediff if the times are invalid would solve the immediate problem.
>
>Thanks for help help.
>
>
>
>SELECT *,datepart(hh,RecDateTime)*60+datepart(mi,RecDateTime) as iStartTime,convert(varchar(10),RecDateTime,110) as justdate,
>
>DATEDIFF( minute, CAST(UpTime1 AS datetime), CAST(DownTime1 AS datetime)) as TotalTimeUp1
>
>from dbo.co_Pat_Tourniquet   (nolock) 
>WHERE meetingnumber=@meetingnumber and noteID=@noteID and isactive=1
> ORDER BY recDateTime Desc
>
>
>Kirk
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform