October 9, 2008 at 4:42 am
Hi all,
i have created a view to calculate with hours (numbers). Whole numbers (1 to 9) is no problem but when i have e.g. 6.5 and i want to multiply this by 60 i get an error in the view: Conversion failed when converting the varchar value '6.5' to data type int. I have tried it with 6,5 and tried using "CAST(beschikbaar * 60 AS float) as BES" and also Convert but i still get the error. How can i resolve this problem?? BTW beschikbaar is nvarchar(50).
This is my full code:
SELECT Mont, Datum, Feestdag, Ziek, Snipperuren, Start1, Stop1, Start2, Stop2, Pauze, VrijSDvan, VrijSDtot, Schoolvan, Schooltot, Gakdag, Diversen,
[1e monteur], [2e monteur], [Zomer SD], [4-daagseweek], beschikbaar, AantalSD, Afd, CASE WHEN vrijsdtot IS NULL
THEN 0 ELSE VrijSDtot - VrijSDvan END AS VrijSD, Stop1 - Start1 AS saldo, CAST(beschikbaar * 60 AS float) AS bes, Stop2 - Start2 AS saldo2, weekdag,
datum2
FROM dbo.TabelConversie
October 9, 2008 at 5:16 am
try changing just the offending columns with CAST or CONVERT, and not the whole formula:
CAST(beschikbaar * 60 AS float)
changes to
CAST(beschikbaarAS float) * 60
I think that will solve your problem.
Lowell
October 9, 2008 at 11:04 pm
Thanks Lowell, so simple.:)
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply