Re: How to convert 1223/100 to 12.23 not 12 in sql server?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




TaeHo Yoo wrote:
> I have a column called "Amount" and this field contains amount as cents.
> So when I get the values of it, I do like "select amount / 100 as
> amount" which basically ignores cents. Do you know how to get cents?
>
> Thanks a lot
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***

Hi YaeHo

You can use convert here i think. eg... (in query analyser )

drop table foo
create table foo
(
amount int not null
)
go
insert foo( amount ) values( 94)
go
insert foo( amount ) values (10)
go
select convert( float , amount )/ 10 from foo

.



Relevant Pages

  • Re: Rounding error when converting from double to int
    ... So we made a money class where the money ... The cents are stored ... the original double amount contains fractions of a cent (due to some ... then it converts to int. ...
    (comp.lang.c)
  • Re: rounding off numbers with excel
    ... the /0.05 changes it to units of 5 cents, the number of 5 cents in the ... the *0.05 returns it to original units ... >>> That formula multiplies the cells and gives me the dollar amount, ... >>> use another cell for a formula. ...
    (microsoft.public.excel.programming)
  • Re: Plan to melt pennies fails to solidify
    ... consistently screw customers out of that amount without being discovered. ... grocery store and guess whether the total is over or under the next ... one or two cents one way or the other on a purchase of more than $10, ... get all the money, ...
    (rec.collecting.coins)
  • Re: Writing "cheques" revisited.
    ... the number of cents when specifying the amount of a withdrawal, ... seen a few machines that let you leave off the cents, ... modern ATMs have anything smaller than a $20 in them -- maybe some ...
    (alt.usage.english)
  • Re: Strip amount from a string
    ... | I have a string where I need to strip out an amount. ... | "1.00 cents per gallon premium to July 2009 NYMEX RBOB Gasoline ... The problem is cents per gallon can ...
    (comp.databases.ms-access)