3 Replies Latest reply: May 7, 2015 10:01 AM by Marco Wedel RSS

    Time rouding

      Hello,

       

      I would like to round time this way :

       

      From original timestamp
      Half hour
      QuarterTime by 5 minutes steps
      21:18:0021:0021:1521:15
      21:39:0021:3021:3021:35
      21:56:0021:3021:4521:55

       

      Rounded values should never be superior to originale timestamp.

       

      So possible values can be :

           * Half hour -> 21:00, 21:30, 22:00, 22:30 ...

           * Quarter -> 21:00, 21:15, 21:30, 21:45 ...

           * Time by 5 minute step -> : 21:00, 21:05, 21:10, 21:15 ...

       

      I created a master calender this way (Field "Horodatage" is a timestamp) :

       

      Calendrier:

      NoConcatenate

      LOAD Distinct

          Horodatage, // Original timestamp

          MakeDate(Year(Horodatage), Month(Horodatage), Day(Horodatage)) as Date,

          Num(Hour(Horodatage), '00') & 'h' as Hour,

          Time(Class(Time(Horodatage),0.5/24), 'hh:mm') as Half_Hour,

          Time(Class(Time(Horodatage),0.5/2/24),'hh:mm') as Quarter,

          Time(Class(Time(Horodatage),0.5/6/24),'hh:mm') as Time_By_5

      Resident Calendrier_TMP;

       

      But i recently noticed that sometimes rounding is correct and sometimes not (yellow):

       

      Do you have an idea why it doesn't work here? Do you have a better calculation method ?

       

      Thank you by advance !