I am pulling data out of a SQL server using pyodbc. The issue is I need to pull data from a certain date frame, however; the date comes across in both an incorrect data type and format. Float64 and 90502(5/02/09 is what I would like.) I am very new to python and far from really even being very good at this and would appreciate any help.

I have tried converting to string, and then strptime but it tells me that the data is in the wrong format. I have also tried the included code, however it does not seem to do what I would like for it to do, as the data still reads as float64, and does not output as desired.

```
import pandas.io.sql as psql
from datetime import datetime
import xlwt
import numpy
date = datetime.strftime(datetime.now(), '%m.%d.%Y')

cnxn = pyodbc.connect(
    driver='{SQL Server}',
    Server='atlmktsql06',
    Database='Repository',
    trusted_connection='yes')
cursor = cnxn.cursor()
sql = ("""select * FROM dbo.tblAS400_Vcresrv WHERE VRRESV='CCVNQ'""")
df = psql.read_sql_query(sql, cnxn)
cnxn.close()
psql.to_datetime(psql.Series(['VRIN']).astype(str), infer_datetime_format=True, errors='coerce')
a = df.head(60)
print(a)
print(df.dtypes)
df.to_excel(r'C:\PythonCode\Testing.xls')

```

The end result as stated above would be for the data to convert to date, and also read appropriately so I can use the sql statement in python to pull by timeframe. Currently, VRIN = Float64 and reads as 90502 and I want VRIN = Date 5/02/09. Thank you again!
['https://Stackoverflow.com/questions/56685913', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8112192/']
One option is to use the base R function `setNames`

```
aggregate_mtcars <- mtcars_copy[, setNames(.(sum(carb)), new_col)]

```

Or you could use `data.table::setnames`

```
aggregate_mtcars <- setnames(mtcars_copy[, .(sum(carb))], new_col)

```
I think what you want is to simply make a copy when doing case 1. 

```
aggregate_mtcars <- copy(mtcars_copy)[, eval(new_col) := sum(carb)]

```

That retains `mtcars_copy` as a separate dataset to the new `aggregate_metcars`, without the new columns.