code: protected function getCalendarDayDownloads($limit=30)
      {
          $arrCalendarDayDownloads = array();
          $CalendarDays = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d")-$limit, date("Y") ) );
          $objCalendarDayDownloads = \Database::getInstance()
                                      ->prepare("SELECT dl.`id`
                                                      , FROM_UNIXTIME(det.`tstamp`,GET_FORMAT(DATE,'ISO')) as datum
                                                      , count(dl.`filename`) as downloads
                                                      , dl.`filename`
                                                  FROM `tl_dlstats` dl
                                                  INNER JOIN `tl_dlstatdets` det on dl.id = det.pid
                                                  WHERE FROM_UNIXTIME(det.`tstamp`,GET_FORMAT(DATE,'ISO')) >=?
                                                  GROUP BY dl.`id`, datum
                                                  ORDER BY datum DESC, `filename`")
                                      ->execute($CalendarDays);
  
          while ($objCalendarDayDownloads->next())
          {
              $viewDate = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], strtotime($objCalendarDayDownloads->datum) );
              $c4d = $this->check4details($objCalendarDayDownloads->id);
              $arrCalendarDayDownloads[] = array(
                                        $viewDate
                                      , $objCalendarDayDownloads->filename
                                      , $this->getFormattedNumber($objCalendarDayDownloads->downloads,0)
                                      , $objCalendarDayDownloads->id
                                      , $c4d
                                      , $objCalendarDayDownloads->downloads
                                      , strtotime($objCalendarDayDownloads->datum)
                                  );
          }
  
          return $arrCalendarDayDownloads;
      }
docs: Get Calendar Day Downloads
  
  @param number $limit optional
  @return array $arrCalendarDayDownloads