Download PostgreSQL 7.1 User`s Guide

Transcript
Chapter 4. Functions and Operators
JUN’,’YYYY MON’) is right, but to_timestamp(’2000 JUN’,’FXYYYY MON’) returns an error,
because to_timestamp expects one blank space only.
If a backslash (\ ) is desired in a string constant, a double backslash (\\ ) must be entered; for
example ’\\HH\\MI\\SS’. This is true for any string constant in Postgres.
Ordinary text is allowed in to_char templates and will be output literally. You can put a substring
in double quotes to force it to be interpreted as literal text even if it contains pattern keywords. For
example, in ’"Hello Year: "YYYY’, the YYYY will be replaced by year data, but the single Y will
not be.
If you want to have a double quote in the output you must precede it with a backslash, for example
’\\"YYYY Month\\"’.
YYYY conversion from string to timestamp or date is restricted if you use a year with more than 4
digits. You must use some non-digit character or template after YYYY, otherwise the year is always
interpreted as 4 digits. For example (with year 20000): to_date(’200001131’, ’YYYYMMDD’)
will be interpreted as a 4-digit year; better is to use a non-digit separator after the year, like
to_date(’20000-1131’, ’YYYY-MMDD’) or to_date(’20000Nov31’, ’YYYYMonDD’).
Table 4-12. Template patterns for numeric conversions
Pattern
Description
9
value with the specified number of digits
0
value with leading zeros
. (period)
decimal point
, (comma)
group (thousand) separator
PR
negative value in angle brackets
S
negative value with minus sign (uses locale)
L
currency symbol (uses locale)
D
decimal point (uses locale)
G
group separator (uses locale)
MI
minus sign in specified position (if number < 0)
PL
plus sign in specified position (if number > 0)
SG
plus/minus sign in specified position
RN
roman numeral (input between 1 and 3999)
TH or th
convert to ordinal number
V
shift n digits (see notes)
EEEE
scientific numbers (not supported yet)
53