pig tutorial - apache pig tutorial - Apache Pig - Date-time Functions - pig latin - apache pig - pig hadoop

What is Date-time functions in Apache Pig ?

  • Date-time functions are used to transform the values and convert them into date and time values.
  • Date-time functions are used in the load script and in the chart expressions.
  • Date -time functions which are done based on a date-time serial number which equals the number of days used in Date-time functions.
  • The Date-time functions are a group of functions which is done for implementing date and time manipulation operations.
  • We can use the date-time functions to perform various operations on dates and times in the Apache pig.
  • The table which is given below is the syntax, functions and the description of Date-time Functions which is done in Apache pig
S.No. Syntax Functions & Description

This function returns a date-time object according to the given parameters. The other alternative for this function are ToDate(iosstring), ToDate(userstring, format), ToDate(userstring, format, timezone)


returns the date-time object of the current time


Returns the day of a month from the date-time object.


Returns the hour of a day from the date-time object.

5GetMilliSecond(datetime)GetMilliSecond (datetime)

Returns the millisecond of a second from the date-time object.


Returns the minute of an hour from the date-time object.


Returns the month of a year from the date-time object.


Returns the second of a minute from the date-time object.


Returns the week of a year from the date-time object.


Returns the week year from the date-time object.


Returns the year from the date-time object.

12AddDuration(datetime, duration)AddDuration(datetime, duration)

Returns the result of a date-time object along with the duration object.

13SubtractDuration(datetime, duration)SubtractDuration(datetime, duration)

Subtracts the Duration object from the Date-Time object and returns the result.

14DaysBetween(datetime1, datetime2)DaysBetween(datetime1, datetime2)

Returns the number of days between the two date-time objects.

15HoursBetween(datetime1, datetime2)HoursBetween(datetime1, datetime2)

Returns the number of hours between two date-time objects.

16MilliSecondsBetween(datetime1, datetime2) MilliSecondsBetween(datetime1, datetime2)

Returns the number of milliseconds between two date-time objects.

17MinutesBetween(datetime1, datetime2)MinutesBetween(datetime1, datetime2)

Returns the number of minutes between two date-time objects.

18MonthsBetween(datetime1, datetime2)MonthsBetween(datetime1, datetime2)

19SecondsBetween(datetime1, datetime2)SecondsBetween(datetime1, datetime2)

Returns the number of seconds between two date-time objects.

20WeeksBetween(datetime1, datetime2)WeeksBetween(datetime1, datetime2)

Returns the number of weeks between two date-time objects.

21YearsBetween(datetime1, datetime2)YearsBetween(datetime1, datetime2)

Returns the number of years between two date-time objects.

Related Searches to Apache Pig - Date-time Functions