以欧元金额替换字符

发布于 2025-01-11 12:10:00 字数 212 浏览 3 评论 0原文

第一篇文章,希望我包含正确的内容,如果没有,请道歉。

我有多种货币金额正在导入数据库中。其中一些是欧元,因此交换“,”和“。”小数点和 1,000 分隔符的位置。我需要将“,”替换为“.”对于美分,但无法找到正确的替换/填充方法来做到这一点。

例如,我有 10.000,00 欧元,我需要它来读取 10,000.00 欧元,我已更新该字段,因此“,”已修复。任何建议表示赞赏。 谢谢

First post so hope I include the right stuff, apologies if not.

I have a mix of currency amounts Im importing into a database. Some of them are EUR and as such swap the "," and "." positions for decimal and 1,000 separator. I need to replace the "," to a "." for the cents but cant find the right replace/stuff method to do it.

For example I have 10.000,00 EUR I need it to read 10,000.00 EUR I have updated the field so the "," is fixed. Any suggestions appreciated.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三人与歌 2025-01-18 12:10:00

如果我们假设您正在谈论 Microsoft SqlServer 以及存储在 char/varchar 列上的金额数据: AmountCol 以指定格式:'10.000,00' 并且您希望以其他格式检索此数据,则可以使用 REPLACE 函数:

SELECT REPLACE(REPLACE(REPLACE(AmountCol,'.','^'),',','.'),'^',',') FROM YourTable

“^”符号的使用是任意的,以确保我们不会转换“.”与 ',',然后将所有 ',' 字符转换为 '.',最后为 '10.000.00'。
如果上述假设错误,您需要提供更多详细信息,例如您正在使用哪个数据库、您从什么介质导入、您使用什么工具导入、目标列的数据类型是什么等?

If we assume that you are talking about Microsoft SqlServer and the amount data stored on char/varchar column: AmountCol in the specified format: '10.000,00' and you want to retrieve this data in the other format, you can use the REPLACE function:

SELECT REPLACE(REPLACE(REPLACE(AmountCol,'.','^'),',','.'),'^',',') FROM YourTable

The use of the '^' symbol is arbitrary, to make sure that we don't convert '.' with ',' and then all ',' chars to '.', ending up '10.000.00'.
If the assumptions above are wrong you need to provide more detail, like which database you are using, what medium you are importing from, what tool do you use to import, what is the datatype of the target column, etc?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文