Date/Time Data

Top  Previous  Next

If an import field is to be received as a date or date/time the default format depends on whether you are using the "international" or "U.S." build of dbFile.

For the international versions, the default format is dd/mm/yyyy
For the U.S. versions, the default format is mm/dd/yyyy

The same formats apply for exports, according to whether the build is international or U.S.

NOTE :: Imported date fields will also be treated as default format if the separator character is a hyphen instead of a forward slash, viz., dd-mm-yyyy for international, mm-dd-yyyy for U.S. builds.

Non-Default Date Formats

To correctly interpret or output date or date/time strings other than the default, you can include an attribute dateform=N, where N is a number specifying another supported format.

Global Specification of Date Format

Using options dateform=N in a control file, or using instead the command-line switch -f N, causes all imported date data to be interpreted or all exported date literals to be written according to the date format corresponding to N.  If you specify the date format at this level, it is your responsibility to ensure that all of the date fields in incoming data are presented consistently in the format anticipated by N.

If an options dateform=N directive is present in the control file, any usage of the switch -f N in the command-line call will be ignored.

Field-level Specification of Date Format

If your input or output record specification includes fields of more than one literal format then the dateform=N attribute should NOT be specified globally.  The attribute should be supplied in the SQL statement, embedded in curly braces after the SQL identifier of the column it is to qualify, for example, {dateform=N}.  (It might be one of a comma-separated list of attribute qualifiers for the field.)

For more details about embedded attributes, refer to the topic dbFile Embedded Field Descriptors in the chapter entitled The SQL Statement.

Date/Time Formats Supported

N

Template

Other Information

11

yyyy/mm/dd

10-character ISO date format

12

mm/dd/yyyy

10-character U.S. standard date format (default in U.S. builds)

13

yyyy/mm/dd hh:mm:ss

19-character date/time, 24-hour clock

14

mm/dd/yyyy hh:mm:ss

19-character date/time, 24-hour clock

15

dd/MMM/yyyy

11 character date where mmm is an English alpha month abbreviation [JAN/FEB/MAR/APR/MAY/JUN/JUL/AUG/SEP/OCT/NOV/DEC]

16

dd/mm/yyyy

10-character international date format (default in international builds)

17

dd/mm/yyyy hh:mm:ss

19-character international date format, 24-hour clock

In all the above formats, output will have slash separators unless forced to be hyphens (see below)


The remaining templates are external formats that can be applied only to fields in fixed-length records

19

yyyymmdd.hhmmss

double timestamp form

20

yyyymmdd

32-bit integer date form

21

yyyyddd

32-bit integer Julian date form-ddd is day in year

22

yyyymmddhhmmss

64-bit integer form


Forcing Hyphen Separators in Output

By default, all exported date and date/time data that use month and day separators will use slashes.  You can force hyphens to be used in place of slashes, as follows:

in a control file, include the options hyphenateDate directive
in a single command-line where the operation is not invoking a control file, use the -h switch

NOTE :: It is not possible to generate a record format that has some date formats using slashes and others using hyphens.