AppLib DATE TO CHAR
From Eigenpedia
(Redirected from LucidDbAppLib DATE TO CHAR)
Contents |
Syntax
APPLIB.DATE_TO_CHAR ( format, date )
Purpose
Uses a format string to format a date. Returns the formatted date or portion of date as a string.
Parameters
- format: format string used to format the date. [VARCHAR]
- date: the date to be formatted [DATE]
- RETURN: formatted date or portion of a date [VARCHAR]
Format string syntax
A format string is a combination of date/time patterns. Only certain combinations of date/time patterns are supported. The date/time patterns are case-sensitive sequences of letters which represent a time or date field.
- format strings which contain year, month, and the day of month
- examples are yyyy-M-d or MMddyyyy
- this will return the date on the specified day, month, and year
- format strings which contain month in year and year
- examples are yyyy-M or MMyyyy
- this will return the date of the first day of the specified month and year
| Field | Form/Pattern | Notes |
|---|---|---|
| Year | yyyy (4 digits) | |
| Month | MM (2 digits) or M (1 or 2 digits) | if using 2 digit form, single digit months will be preceded by a 0 |
| Day of month | dd (2 digits) or d (1 or 2 digits) | if using 2 digit form , single digit days will be preceded by a 0 |
Example
VALUES( APPLIB.DATE_TO_CHAR('MMM d - EEEE #F yyyy', DATE'2006-10-4'),
APPLIB.DATE_TO_CHAR('MM', DATE'2006-10-4'),
APPLIB.DATE_TO_CHAR('ww-yyyy', DATE'2007-7-3'),
APPLIB.DATE_TO_CHAR('yyyy-M', DATE'2007-7-3') )
RETURNS:
| APPLIB.DATE_TO_CHAR('MMM d - EEEE #F yyyy', DATE'2006-10-4') | APPLIB.DATE_TO_CHAR('MM', DATE'2006-10-4') | APPLIB.DATE_TO_CHAR('ww-yyyy', DATE'2007-7-3') | APPLIB.DATE_TO_CHAR('yyyy-M', DATE'2007-7-3') |
|---|---|---|---|
| Oct 4 - Wednesday #1 2006 | 10 | 27-2007 | 2007-7 |
Untried/Untested Functionality
The functionality listed under this section has not been fully tested and is not considered supported at this time. The expected behavior for the usage patterns below have not been well-specified and they should be used at your own risk.
- Any format strings which use combinations of date/time patterns other than the ones listed above in the Format String Syntax section.
- Additional date/time patterns in the table below.
Any combination of the following fields in the table below can be added to a format string. NOTE: the format string fields are case sensitive.
| Field | Long Form | Short Form |
|---|---|---|
| Year | yy (2 digits) | |
| Month | MMM (name) | |
| Day of week | EEEE | EE |
| Day of week in month | F (e.g., 3rd Thursday) | |
| Day in year | DDD (3 digits) | D (1, 2, or 3 digits) |
| Week in month | WW | |
| Week in year | ww | |
| Era (BC/AD) | G |

