| |

VerySource

 Forgot password?
 Register
Search
View: 886|Reply: 4

Take currency format and calculate

[Copy link]

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-26 19:00:01
| Show all posts |Read mode
How to format and calculate currency data from SQL?
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-2-19 00:00:02
| Show all posts
Formatting is best done in the foreground
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-2-19 06:30:01
| Show all posts
money
Reply

Use magic Report

0

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-19 14:00:01
| Show all posts
Currency data does not need to be enclosed in single quotes ('). However, the currency value must be preceded by the appropriate currency symbol. For example, to specify 100 pounds, use£ 100.

Money and smallmoney are limited to 4 digits after the decimal point. If you require more digits after the decimal point, use the decimal data type.

Use periods to separate local monetary units (such as cents) from the overall monetary unit. For example, 2.15 means 2 yuan and 15 points.

Although these data types include a comma separator in their display, the comma separator cannot be used in money or smallmoney constants. Comma separators can only be specified in strings that are explicitly converted to money or smallmoney, such as:

USE Northwind
GO
CREATE TABLE TestMoney (cola INT PRIMARY KEY, colb MONEY)
GO
SET NOCOUNT ON
GO

-The following three INSERT statements work.
INSERT INTO TestMoney VALUES (1, $ 123.45)
GO
INSERT INTO TestMoney VALUES (2, $ 123123.45)
GO
INSERT INTO TestMoney VALUES (3, CAST ('$ 444,123.45' AS MONEY))
GO

-This INSERT statement gets an error because of the comma
-separator in the money string.
INSERT INTO TestMoney VALUES (3, $ 555,123.45)
GO
SET NOCOUNT OFF
GO
SELECT * FROM TestMoney
GO
Reply

Use magic Report

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-4-4 11:30:02
| Show all posts
Thanks, I solved it with another method
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list