Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split dollars from cents on return from DB

Status
Not open for further replies.

penguinspeaks

Technical User
Nov 13, 2002
234
US
Is there a way I can take the record being returned say 12.75, in which I would display as money, and separate the dollars(left side of decimal) from the cents(right side of decimal) and assign a variable to each of them?

end result would be something like Vcents = .75 and Vdollar = 12 or along those lines.

I wish to display the record return with different size fonts on the cents as I will have on the dollar part. If there is an easier way of doing this, please let me know as well.

Thanks in advance

Bam
 
something like that
declare @tot as money

select @tot=2.75

select Vdollar = cast(FLOOR(@tot) as int),
Vcents = cast((@tot - FLOOR(@tot)) * 100 as int)
 
I probable should have mentioned this is on a classic asp page and it doesn't like the @ for somereason.

 
first at all it is possible to use @ in classic asp.
and second I used @tot just as value holder
if your value in database it would be something like
select Vdollar = cast(FLOOR(yourFieldName) as int),
Vcents = cast((@tot - FLOOR(yourFieldName)) * 100 as int) from YourTable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top