Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
steamngn
Constraint Violating Yak Guru
306 Posts |
Posted - 2005-04-23 : 13:36:57
|
'Morning gang,Consider the following code, if you will:select recvd_cost,coalesce(commnt_2,'')+'/'+ replace(recvd_cost,'.','')as restfrom po_recvr_hist_lin This works great, almost...The Recvd_cost field comes over with 2 added zeros after the amount (ie $3.9500 is 39500), and I need to trim off the last zero (3950).At the moment my two good brain cells are playing tiddlywinks , and I can't seem to get this right.A little help, please?AndyThere's never enough time to type code right, but always enough time for a hotfix... |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-04-23 : 14:15:55
|
| What datatype is Recvd_cost? Money? If so the convert function has an optional third parameter that lets you control 2 or 4 decimal places (and separators between the thousands - the combinations available are a bit limited!)Kristen |
 |
|
|
steamngn
Constraint Violating Yak Guru
306 Posts |
Posted - 2005-04-23 : 14:50:45
|
Ahh,That was it. Recvd_cost is decimal(15,4), so the fix is:select recvd_cost,coalesce(commnt_2,'')+'/'+ replace(cast(recvd_cost as decimal (15,3)),'.','')as restfrom po_recvr_hist_lin Thanks for the wakeup call!AndyThere's never enough time to type code right, but always enough time for a hotfix... |
 |
|
|
|
|
|
|
|