9 Replies Latest reply: Sep 3, 2015 11:36 AM by bruno bertels RSS

    group hours by half hour interval : good practice script ?

    bruno bertels

      Hi community

       

      I have a timestamp field named (@1) with this format "02/09/2015  08:36:24"

      using hour() function i created a hour dimension to dispatch events by hour

       

      Nethertheless I need in fact group hour interval like below :

      8:30 to 9:30

      9:30 to 10:30

      10:30 to 11:30

      11:30 to 12:30

      and

      13:30 to 14:30

      14:30 to 15:30

      15:30 to 16:30

      16:30 to 17:30

       

      Events before 8:30 should be attached to the 8:30 to 9:30 group

      Events between 12:30 to 13:00 should be attached to 11:30 to 12:30 group

      Events between 13:00 to 13:30 should be attached to 13:30 to 14:30 group

      Then Events after 17:30 should be attached to 16:30 to 17:30 group

       

      to achieve this requirments in my script i put this and it's works well

       

      // test group by tranche horaire
      if(right(@1,8)<='09:30:00','8h30 à 9h30',
      if(right(@1,8)<='10:30:00','9h30 à 10h30',
      if(right(@1,8)<='11:30:00','10h30 à 11h30',
      if(right(@1,8)<='13:00:00','11h30 à 12h30',
      if(right(@1,8)<='14:30:00','13h30 à 14h30',
      if(right(@1,8)<='15:30:00','14h30 à 15h30',
      if(right(@1,8)<='16:30:00','15h30 à 16h30',   

          if(right(@1,8)>'16:30:00','16h30 à 17h30','autres'))))))))as "Interval",

       

      So is this solution a good one or is there another way to do the same ?

      Thanks in advance for your help

       

      Bruno