Info |
---|
This article is posted on the CDAP Doc wiki and will be maintained here: https://cdap.atlassian.net/wiki/spaces/DOCS/pages/1224900611/Calculating+time+between+Timestamps |
This document describes how to calculating different units of time between two timestamps using Wrangler. For example, a user may want to calculate the number of months between two calendar dates. This assumes the columns are already timestamps. If they are strings, use the parse-as-simple-date directive to parse the string into a timestamp.
...
set-column :month_diff 12 * (dt1.getYear() - dt2.getYear()) - + (dt1.getMonthValue() - dt2.getMonthValue())
...