ybload Date Formats
This section describes the date formats supported by ybload operations. A ybload date format consists of two parts:
- A date style, which describes how a date value is expressed. For example,
YMDstyle means that a date value is expected to have year, month, and day pieces, in that order. - A date delimiter, which is the character that separates the date parts, such as a hyphen (
-) or a backslash (/).
You can define acceptable date formats within --date-field-options, using the following syntax. In this example, MONDY2 is the date style and - is the delimiter:
"formats":[{"style":"MDY","delim":"-"}]You can also define date formats within --per-field-options, when the field in question is being loaded into a DATE column.
As a shortcut, you can define date styles with the --date-style option, but you cannot set the delimiter with that option.
Supported Date Styles
The following table lists the legal date styles that you can use within --date-field-options, --per-field-options, and --date-style.
| Date Mask | Examples |
|---|---|
| YMD | 2016-08-13 |
| DMY | 13-08-2016 |
| MDY | 08/13/2016 |
| MONDY | Aug 13 2016 |
| DMONY | 13 Aug 2016 |
| Y2MD | 16-08-13 |
| DMY2 | 13-08-16 |
| MDY2 | 08/13/16 |
| MONDY2 | Aug 13 16 |
| DMONY2 | 13 Aug 16 |
Note: If you do not specify date styles explicitly, the default styles that are accepted are YMD, DMONY, and MONDY.
Note the following requirements for defining date styles:
- If you are using a date style with a two-digit year (
Y2), you need to set the--y2baseoption. - The bulk load parser recognizes
YMD,DMONY, andMONDYautomatically, but the other styles need to be set explicitly. - The
DMYandMDYdate styles are ambiguous and cannot be specified together in oneybloadcommand.
Supported Date Delimiters
The delim setting defines the delimiter between the day, month, and year parts of a date. You can use default supported delimiters within the date string or set a different delimiter.
The following delimiters are supported:
auto(the default), which means any one of the following: " ", ".", "-", "/", "|", ","- Empty string (
""). Note thatautoalso allows the empty string ("") whenstyleis set toYMD. - Any other explicitly specified character sequence. You may have fields to load that have special delimiter strings.
Examples
The following --date-field-options setting allows dates with two different date styles to be loaded from the same file:
--date-field-options '{"formats":[{"style":"YMD"},{"style":"MDY"}]}'In this case, dates such as 2016-10-05 and 10-05-2016 can be loaded.
The following example extends the first by specifying that the delimiter for both date styles must be a tab character (\t):
--date-field-options '{"formats":[{"style":"YMD","delim":"\t"},{"style":"MDY","delim":"\t"}]}'In this case, dates such as 2016 10 05 and 10 05 2016, where the white space represents a tab, can be loaded.
The following example sets the y2base year to 1968 and the date style to MDY2:
--date-field-options {"y2base":1968,"formats":["MDY2"]}In this case, dates such as 10-11-10 are understood to refer to the year 2010.
Parent topic:ybload Command