2 Replies Latest reply on Jul 20, 2017 7:08 PM by bill.cunningham

    Guys in wind industry starving for Datetrunc to 10 minutes

    Dean Han


      I'm doing date analysis in wind power industry.

      We use time series data from wind turbines' sensors which usually with a time stamp in 1 Hz. In many cases we would aggregate some measurements to 10 minutes average value.

      So I really need a handy function that can truncate the time stamp to every 10 minute.


      In R it's pretty easy using "lubridate" library (as below), but a tableau native function must be better.


      > library(lubridate)
      > x <- as.POSIXct("2009-08-03 12:26:59.23")
      > floor_date(x, "second")
      [1] "2009-08-03 12:26:59 CST"
      > floor_date(x, "minute")
      [1] "2009-08-03 12:26:00 CST"
      > floor_date(x, "5 mins")
      [1] "2009-08-03 12:25:00 CST"
      > floor_date(x, "10 mins")
      [1] "2009-08-03 12:20:00 CST"
      > floor_date(x, "2 mins")
      [1] "2009-08-03 12:26:00 CST"



      floor_date(x, unit = "seconds")

      floor_date takes a date-time object and rounds it down to the nearest boundary of the specified time unit.




      a vector of date-time objects


      a character string specifying the time unit or a multiple of a unit to be rounded to. Valid base units are second, minute, hour, day, week, month, bimonth, quarter, halfyear, or year. Arbitrary unique English abbreviations as in period constructor are also supported. Rounding to multiple of units (except weeks) is supported from v1.6.0.