apache pig provides the following date and time functions −
| s.n. | functions & description |
|---|---|
| 1 |
todate(milliseconds)
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) |
| 2 |
currenttime()
returns the date-time object of the current time. |
| 3 |
getday(datetime)
returns the day of a month from the date-time object. |
| 4 |
gethour(datetime)
returns the hour of a day from the date-time object. |
| 5 |
getmillisecond(datetime)
returns the millisecond of a second from the date-time object. |
| 6 |
getminute(datetime)
returns the minute of an hour from the date-time object. |
| 7 |
getmonth(datetime)
returns the month of a year from the date-time object. |
| 8 |
getsecond(datetime)
returns the second of a minute from the date-time object. |
| 9 |
getweek(datetime)
returns the week of a year from the date-time object. |
| 10 |
getweekyear(datetime)
returns the week year from the date-time object. |
| 11 |
getyear(datetime)
returns the year from the date-time object. |
| 12 |
addduration(datetime, duration)
returns the result of a date-time object along with the duration object. |
| 13 |
subtractduration(datetime, duration)
subtracts the duration object from the date-time object and returns the result. |
| 14 |
daysbetween(datetime1, datetime2)
returns the number of days between the two date-time objects. |
| 15 |
hoursbetween(datetime1, datetime2)
returns the number of hours between two date-time objects. |
| 16 |
millisecondsbetween(datetime1, datetime2)
returns the number of milliseconds between two date-time objects. |
| 17 |
minutesbetween(datetime1, datetime2)
returns the number of minutes between two date-time objects. |
| 18 |
monthsbetween(datetime1, datetime2)
returns the number of months between two date-time objects. |
| 19 |
secondsbetween(datetime1, datetime2)
returns the number of seconds between two date-time objects. |
| 20 |
weeksbetween(datetime1, datetime2)
returns the number of weeks between two date-time objects. |
| 21 |
yearsbetween(datetime1, datetime2)
returns the number of years between two date-time objects. |