If you want the benefits of a SelectQuery, but with the more fine-grained control over the SQL, you can always use the where() method to inject (sanitised) raw SQL into the WHERE clause. e.g

$query = db_select('Project', 'p');
$query-&gt;fields('p', array('submissions', 'date_time'));
$query-&gt;condition('p.user_id', $user-&gt;uid);

// Fetch only records where date_time is greater than 30 days ago
$query-&gt;where('date_time &gt; DATE_ADD(NOW(), INTERVAL -30 DAY)');

$results = $query-&gt;execute()-&gt;fetchAll();
foreach($results as $r) {
  $rows[] = array(strtotime(date("Y-m-d", $r-&gt;date_time))*1000, $r-&gt;numberOfPackages);
}


I don't know of any 'structured' way to get those sort of advanced conditions into a SelectQuery object so resorting to plain ol' SQL is necessary sometimes.

How to retrieve datetime from database in Drupal?
I have a set of equations which I'd like to annotate with overbraces (or anything else at your discretion). However they are fixed to the top of each individual item which they reference, which looks messy. Can I make them all at a fixed height above the equations?



\documentclass{article}
\usepackage{graphicx,amsmath}

\begin{document}


\begin{align}
\overbrace{\dfrac{\partial\rho \mathbf{U}}{\partial t}}^{\text{time derivative}}+\overbrace{\mathbf{U}\cdot \nabla \rho\mathbf{U}}^{\text{advection}}=&amp;\overbrace{-\nabla P}^{\text{pressure gradient}}+\overbrace{\mu\nabla^2\mathbf{U}}^{\text{diffusion}}+\overbrace{\rho \mathbf{g}}^{\text{body force}},&amp;\quad \text{\emph{momentum eq.}}\label{eq:mom}\\
   \dfrac{\partial \rho}{\partial t}+\nabla\cdot \rho\mathbf{U}=&amp;\, 0,&amp;\quad \text{\emph{continuity eq.}}\label{eq:cont}
\end{align}

\end{document}

