23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Date formats<br />

Example<br />

Date formats<br />

192<br />

format_string<br />

Specifies the format of the output. <strong>SQL</strong> ignores the format string if the expression<br />

argument does not evaluate to a date or time.<br />

Supply the format strings, enclosed in single quotation marks, as the second argument to the<br />

function. The format strings are case sensitive. For instance, <strong>SQL</strong> replaces DAY with all<br />

uppercase letters, but follows the case of Day.<br />

The following example illustrates the difference between how a date value displays with and<br />

without the TO_CHAR function:<br />

SELECT C1 FROM T2;<br />

C1<br />

--<br />

09/29/1952<br />

1 record selected<br />

SELECT TO_CHAR(C1, 'Day, Month ddth'),<br />

TO_CHAR(C2, 'HH12 a.m.') FROM T2;<br />

TO_CHAR(C1,DAY, MONTH DDTH) TO_CHAR(C2,HH12 A.M.)<br />

--------------------------- ---------------------<br />

Monday , September 29th 02 p.m.<br />

1 record selected<br />

A date-format string can contain any of the following format keywords along with other<br />

characters. The format keywords in the format string are replaced by corresponding values to<br />

get the result. The other characters are displayed as literals. Table 46 lists the date formats and<br />

their corresponding descriptions.<br />

Table 46: Date formats and descriptions (1 of 2)<br />

Date<br />

format Description<br />

CC The century as a two-digit number.<br />

YYYY The year as a four-digit number.<br />

YYY The last three digits of the year.<br />

YY The last two digits of the year.<br />

Y The last digit of the year.<br />

Y,YYY The year as a four-digit number with a comma after the first digit.<br />

Q The quarter of the year as a one-digit number (with values 1, 2, 3, or 4).<br />

MM The month value as a two-digit number (in the range 01-12).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!