Skip to main content

## date_iso

The date_iso command converts dates in user formats to the ISO YYYY-MM-DD format. You can specify the format of the input date using a mask. Once dates are in ISO format, you can reformat them with the date_format command. If a field cannot be converted to ISO format, it is left unchanged.
See also: date_format

Flag | Req'd? | Description
-f fields | Yes | A list of fields to attempt to convert.
-m mask | Yes | The mask that specifies how the parts of the field are to be treated. The mask must be exactly five characters long. Three of these characters must be one each of 'd', 'm' and 'y'', specifying positions of day, month and year. The remaining two characters must be non-alphanumeric and specify the separators between the dmy characters. Examples of masks: d/m/y - reads dates like '1/12/2000', '19/Aug/2005' m,d/y - reads dates like '1,30/200', 'January, 12/2010' d m y - reads dates like '01 01 2000' , '4 Jul 2002'
-cy year | No | Specifies a base year to use for dates that have two-digit year values. The default base year is 1930, so the date '1/1/01' means '1/1/2000' and '1/1/36' means '1/1/1936'
-mn names | No | Specifies a comma-separated list of month names. There must be exactly twelve names and they must appear in the order of the months.
-bdl | No | Outputs only records that fail the date conversion.
-bdx | No | Excludes records that fail the date conversion from output.

The following example reads the file birthdays.csv and transforms the dates in the second column into ISO format:
csvfix date_iso -f 2 -m 'd/m/y' data/birthdays.csv
which produces:
"Peter","2000-08-20"
"Jane","1970-02-12"
"Bill","1971-06-14"
"Anna","1976-12-27"

Created with the Personal Edition of HelpNDoc: Full-featured EBook editor

####