mssql date format

MRAB python at mrabarnett.plus.com
Mon Sep 12 19:52:59 EDT 2016


On 2016-09-13 00:06, sum abiut wrote:
> Thanks for the response,
> i pulling data from an mssql database and i need to convert the date 
> column. how to i covert and pass it to my template. i am using Django
>
> this is what i did
>
> conn=pymssql.connect(server,username,password,database)
>     #cus=conn.cursor()
>     cus=conn.cursor(as_dict=True)
>     cus.execute("SELECT 
> account_code,currency_code,balance_date,debit,credit,net_change,home_net_change 
> FROM glbal where account_code= '50101001CORP'    ")
>
>     return render_to_response('revenue_budget.html',locals())
>
>
> how to i  convert the balance_date with the code below:
>
>
>
>             import datetime
>             datetime.datetime.fromordinal(733010)
>
> datetime.datetime(2007, 11, 30, 0, 0)
>
>
The documentation for pymssql should tell you how to get the values of 
the fields.

In the case of the 'balance_date' field, just pass its value into 
datetime.datetime.fromordinal like the code I gave.



More information about the Python-list mailing list