Группировка данных по дням, по месяцам или по годам в MSSQL

По дням:

select convert(char(8),Date_and_Time,112) mydate, count(calls_id)
from calls
group by convert(char(8),Date_and_Time,112)
order by mydate

По месяцам:

select convert(char(6),Date_and_Time,112) mydate, count(calls_id)
from calls
group by convert(char(6),Date_and_Time,112)
order by mydate 

По годам:

select convert(char(4),Date_and_Time,112) mydate, count(calls_id)
from calls
group by convert(char(4),Date_and_Time,112)
order by mydate

Python подключение к базе данных MSSQL

import pyodbc
cnxn = pyodbc.connect("Driver={SQL Server};"
                      "Server=srvmssql;"
                      "Database=mydatabase;"
                      "Trusted_Connection=yes;")
cursor = cnxn.cursor()
cursor.execute('SELECT TOP 10 * FROM MYTABLE')
for row in cursor:
    print('row = %r' % (row,))
input()