<p>I have a table called logs which has a datetime field. 
I want to select the date and count of rows based on a particular date format. </p>

<p>How do I do this using SQLAlchemy?</p>

I don't know SQLAlchemy, so I could be off-target.  However, I think that all you need is:
```
```
SELECT date_formatter(datetime_field, "format-specification") AS dt_field, COUNT(*)
    FROM logs
    GROUP BY date_formatter(datetime_field, "format-specification")
    ORDER BY 1;
```
```
OK, maybe you don't need the ORDER BY, and maybe it would be better to re-specify the date expression.  There are likely to be alternatives, such as:
```
```
SELECT dt_field, COUNT(*)
    FROM (SELECT date_formatter(datetime_field, "format-specification") AS dt_field
              FROM logs) AS necessary
    GROUP BY dt_field
    ORDER BY dt_field;
```
```
And so on and so forth.  Basically, you format the datetime field and then proceed to do the grouping etc on the formatted value.