title: How to use datetime column as a time series in Grafana using Postgres
body: <p>Hi guys I have a table in Postgres basically storing a door time entry. for example everytime you scan a card to open a door we store the datetime and your id
  table format</p>
  <blockquote>
  <p>CREATE TABLE doorentry(date CHARACTER VARYING(50),id VARCHAR(255))</p>
  </blockquote>
  <p>dataset looks like this</p>
  <blockquote>
  <p>[{ &quot;id&quot; : &quot;aadams1&quot;, &quot;date&quot; : &quot;09-10-2022-14:55:30&quot;},{ &quot;id&quot; : &quot;jjames2&quot;, &quot;date&quot; : &quot;09-10-2022-14:55:31&quot;}]</p>
  </blockquote>
  <p>I would like to group the dataset by their timestamp per hour.
  I have sort of achieved that with</p>
  <pre><code>SELECT SUBSTRING(date,0,16) AS byhour, COUNT(id)
  FROM doorentry GROUP BY byhour ORDER BY byhour; 
  </code></pre>
  <p>that looks something like this
  <a href="https://i.stack.imgur.com/Ci1iE.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>Would appreciate any help showing this data as a time series graph/new query to be able to use Grafana  drop down to show data for the last day or hour like this:
  <a href="https://i.stack.imgur.com/xbfD3.png" rel="nofollow noreferrer">enter image description here</a></p>