Add example of MONEY casting to numeric if locale is known.
authorBruce Momjian
Tue, 27 Nov 2007 16:46:36 +0000 (16:46 +0000)
committerBruce Momjian
Tue, 27 Nov 2007 16:46:36 +0000 (16:46 +0000)
doc/src/sgml/datatype.sgml

index 293605396964f0aa78de10f5edc20eb89de08a5a..699884d8003400f363af5be5cdfcf06d7b7882b9 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
  
   Data Types
@@ -848,8 +848,14 @@ ALTER SEQUENCE tablename_
 
 SELECT 1234::text::money;
 
-    There is no simple way of doing the reverse using a locale-neutral
-    method, namely casting a money value to a numeric type.
+    There is no simple way of doing the reverse in a locale-independent
+    manner, namely casting a money value to a numeric type.
+    If you know the currency symbol and thousands separator you can use
+    regexp_replace():
+
+SELECT regexp_replace('52093.89'::money::text, '[$,]', '', 'g')::numeric;
+
+