1.int Pack String
Select CAST (1234 as text)
Select to_char (1234, '9 ')
2.string Turn int
Cast (asNUMERIC)
--5 attached: PostgreSQL type conversion function
Function |
Return Type |
Description |
Example |
To_char (Timestamp, text
)
|
Text |
Convert time stamp to string |
To_char (Current_timestamp, ' HH12:MI:SS ') |
to_char interval, text |
Text |
convert interval to string |
to_char (interval ' 15h 2m 12s ', ' HH24:MI:SS ') |
to_char int, Text |
text |
convert integer to String |
to_char ("999") |
to_char ( double precision , text ) |
text |
convert real/double precision to string |
to_char (125.8::real, ' 999d9 ') |
To_char ( numeric, text ) |
Text |
Convert numeric to String |
To_char ( -125.8, ' 999d99s ') |
To_date (Text, text ) |
Date |
Convert String to date |
To_date (' Dec ', ' DD Mon YYYY ') |
to_number text, Text |
numeric |
convert string to numeric |
to_number (' 12,454.8-', ' 99g999d9s ') |
to_timestamp text, Text |
timestamp With time zone |
convert string to time stamp |
Br>to_timestamp (' 05 dec 2000 ', ' dd mon yyyy ') |
To_timestamp ( Double precision ) |
Timestamp with time zone |
Convert Unix epoch to time stamp |
To_timestamp (1284352323) |
PostgreSQL type Conversion