November 28, 2006 at 6:46 am
How do I cast the figure 2000.00 to the integer 2000?
November 28, 2006 at 7:26 am
Select CONVERT(INT, YouColHere) FROM dbo.YourTable WHERE Whatever = @SomeParam
BTW Presenting the data in the correct format is often better left to the front end but there are a lot of exceptions!
November 28, 2006 at 7:33 am
CAST(ROUND(year, 0) AS int) AS Expr1
is an alternative solution
November 28, 2006 at 8:42 am
You shouldn't need to do a cast at all in general. For example:
DECLARE @fp MONEY
DECLARE @i INT
SET @fp = 2000.00
SET @i = @fp
will work fine.
If you run SELECT @fp after this you'll get 2000.00, and if you run SELECT @i you'll get 2000. BOL is pretty good for answering questions like this.
Thanks,
Bart
November 28, 2006 at 9:31 am
SELECT CAST(2000.00 AS INT)
November 28, 2006 at 9:44 am
Why? Not trying to be a smart guy here but why do you want to do such a conversion? A lot of times, folks will come to the conclusion that there's something that they need to do and post only that... and that sometimes means they are missing a much better solution. You could start off by explaining what the number 2000.00 represents and why you need to display it as an INT. For example, is it a date/year? If so, you may be making a huge mistake by handling it separately from the Month and Day....
Like I said, what does the number 2000.00 represent and why do you think it needs to be converted?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply