October 9, 2008 at 4:18 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??
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 4:37 am
Hey, another W van Dijk! 🙂
Post this question in the T-SQL forum
Wilfred
The best things in life are the simple things
October 9, 2008 at 4:43 am
Ok, done.
October 9, 2008 at 6:56 am
If you fixed it, post the solution so that anyone else reading the post knows how to solve it too.
Did you multiply by 60.0?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
October 9, 2008 at 11:13 pm
Changed CAST(beschikbaar * 60 AS float) into CAST(beschikbaar as float)*60 and it works. Thanks for the replies.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply