SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 dividing money by int is returning an int
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

esthera
Flowing Fount of Yak Knowledge

1379 Posts

Posted - 02/25/2013 :  02:35:27  Show Profile  Reply with Quote
I am doing

declare @temp money,
@numdays int

select @numdays=35

select @temp=@numdays/30
select @temp as temp


it's returning 1 but it should return 1.1666
what do I need to do to return it as a money or float?
num days will always be a integer but dividing it by 30 should not

webfred
Flowing Fount of Yak Knowledge

Germany
8683 Posts

Posted - 02/25/2013 :  03:01:20  Show Profile  Visit webfred's Homepage  Reply with Quote
take 30.0 instead of 30


Too old to Rock'n'Roll too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 02/25/2013 :  04:09:27  Show Profile  Reply with Quote
see

http://beyondrelational.com/modules/2/blogs/70/posts/10825/beware-of-implicit-conversions.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000