title: How to use function - CAST(datetime as date) of SQL Server in sqlalchemy?
body: <p>I have a table which has columns - <code>id(int)</code>, <code>date(DateTime)</code>, <code>value(float)</code>. I wanted to output daily average group by date of all rows which has <code>id=2.</code> </p>
  
  <p>I wrote following sql query for that and query was working fine:</p>
  
  <pre><code>select cast(date as date), avg(value) from table where id=2 group by cast(date as date)
  </code></pre>
  
  <p>For the same problem, if I wanted to execute in sqlalchemy, I was using following expression :</p>
  
  <pre><code>&gt;&gt; from sqlalchemy import sql, types
  &gt;&gt; x = sql.cast(Table.date, types.Date)
  </code></pre>
  
  <p>But when I tried executing x, I got following error :</p>
  
  <pre><code>&gt;&gt; x.execute()    
  ArgumentError: Not an executable clause: CAST(Table.date AS DATETIME)
  </code></pre>
  
  <p>which means that SQL Server is considering that <code>types.Date as DateTime</code>. 
  Please ignore the ArgumentError. What I am trying to focus on is that internal sql query is using <code>CAST(Table.date AS DATETIME)</code> rather than <code>CAST(Table.date AS DATE)</code>
  Is there any way so that I can convert DateTime to Date in sqlalchemy?</p>