Date field conversions
InfoSphere® DataStage® performs no automatic type conversion of date fields. Either an input data set must match the operator interface or you must effect a type conversion by means of the modify operator.
The following table lists the conversions involving the date field.
Conversion Specification |
Description |
---|---|
dateField = date_from_days_since[date] (int32Field) | date from days since Converts an integer field into a date by adding the integer to the specified base date. The date must be in the format yyyy-mm-dd. |
dateField = date_from_julian_day(uint32Field) | date from Julian day |
dateField = date_from_string [date_format | date_uformat]
(stringField) dateField = date_from_ustring [date_format | date_uformat] (ustringField) |
date from string or ustring Converts the string or ustring field to a date representation using the specified date_format. By default, the string format is yyyy-mm-dd. date_format and date_uformat are described in date formats. |
dateField = date_from_timestamp(tsField) | date from timestamp Converts the timestamp to a date representation. |
int8Field = month_day_from_date(dateField) | day of month from date |
int8Field = weekday_from_date [originDay](dateField) | day of week from date originDay is a string specifying the day considered to be day zero of the week. You can specify the day using either the first three characters of the day name or the full day name. If omitted, Sunday is defined as day zero. The originDay can be either single- or double-quoted or the quotes can be omitted. |
int16Field = year_day_from_date(dateField) | day of year from date (returned value 1-366) |
int32Field = days_since_from_date[source_date] (dateField) | days since date Returns a value corresponding to the number of days from source_date to the contents of dateField. source_date must be in the form yyyy-mm-dd and can be quoted or unquoted. |
uint32Field = julian_day_from_date(dateField) | Julian day from date |
int8Field = month_from_date(dateField) | month from date |
dateField = next_weekday_from_date[day] (dateField) | next weekday from date The destination contains the date of the specified day of the week soonest after the source date (including the source date). day is a string specifying a day of the week. You can specify day by either the first three characters of the day name or the full day name. The day can be quoted in either single or double quotes or quotes can be omitted. |
dateField = previous_weekday_from_date[day] (dateField) | previous weekday from date The destination contains the closest date for the specified day of the week earlier than the source date (including the source date) The day is a string specifying a day of the week. You can specify day using either the first three characters of the day name or the full day name. The day can be either single- or double- quoted or the quotes can be omitted. |
stringField = string_from_date[date_format | uformat]
(dateField) ustringField = ustring_from_date [date_format | date_uformat] (dateField) |
strings and ustrings from date Converts the date to a string or ustring representation using the specified date_format. By default, the string format is yyyy-mm-dd. date_format and date_uformat are described in date formats. |
tsField = timestamp_from_date[time](dateField) | timestamp from date The time argument optionally specifies the time to be used in building the timestamp result and must be in the form hh:nn:ss. If omitted, the time defaults to midnight. |
int16Field = year_from_date(dateField) | year from date |
int8Field=year_week_from_date (dateField) | week of year from date |
A date conversion to or from a numeric field can be specified with any InfoSphere DataStage numeric data type. InfoSphere DataStage performs the necessary modifications and either translates a numeric field to the source data type shown above or translates a conversion result to the numeric data type of the destination. For example, you can use the conversion month_day_from_date to convert a date to an int8, or to an int16, int32, dfloat, and so on