title: data.table group by 2 weeks or 6 months
body: <p>I have a data.table where I have several columns with number of items, date, etc. However I would like to group some sums by a period of 2 weeks or 6 months. I have already applied the grouping by week, 1 month and quarter as follows:</p>
  
  <pre><code>total.national.sales.by.category &lt;- table[, sum(total_price), 
                                            by= .(week(local_created_day),category)]
  </code></pre>
  
  <p>where <code>local_created_Day</code> is the date column and <code>total_price</code> is just a numeric value column. </p>
  
  <p>However, I would like to group the table by periods of 2 weeks or 6 months, but there is no built in function in data.table to do it (ex. in data.table you put quarter(local_created_Day) in the 'by' statement and it group it by 3 month period or by 'week()' and it groups it by week). </p>
  
  <p>The <code>local_created_Day</code> column format is something like '2019-08-07' as Date object.</p>