datetime Format Conversion Examples

You can use the Variable operator to convert datetime formats.

From the Variable operator, using the Define Variables dialog box, you can specify a different output datetime format than that of the input column.



You can override the default list of datetime data types (set by the Administrator in the Datetime Formats Preferences dialog box, detailed in the TIBCO® Data Science Team Studio Installation and Administration ) as long as the Joda-Time API formatting is followed.

You can use a Pig Script user-defined function (UDF) to generate a new value from a datetime string, such as the GetMonth and GetDay functions shown in the following image.



For a full list of available datetime related Pig functions, see Apache Pig DateTime Functions.

Because some Pig functions have issues handling null values, instead use the following Team Studio alternatives for these functions.

Pig Function Alpine Alternative
AddDuration AddDurationAlpine
SubtractDuration SubtractDurationAlpine
MilliSecondsBetween MilliSecondsBetweenAlpine
SecondsBetween SecondsBetweenAlpine
MinutesBetween MinutesBetweenAlpine
HoursBetween HoursBetweenAlpine
DaysBetween DaysBetweenAlpine
WeeksBetween WeeksBetweenAlpine
MonthsBetween MonthsBetweenAlpine
YearsBetween YearsBetweenAlpine
Tip: For assistance writing Pig Functions, click Pig Syntax.