Python - how to get a python datetime from a sql DateTime

moody31415moody31415 Posts: 8
edited July 20, 2015 5:15AM in SQL Data Generator
I'm trying to generate data from a previous column - basically I want to figure out "week starting" (eg, value is always a Monday) given a datetime column.

What I'd like to do is treat the SQL DateTime column as a python datetime (https://docs.python.org/2/library/datet ... me-objects), which would allow me to do this in a python script:

foo = otherColumn
dayOfWeek = foo.date().weekday()
return foo.date().AddDays(-dayOfWeek)

Of course, python doesn't have an AddDays, but I could use timedelta if necessary.

How do I convert a sql DateTime to a python datetime?

Thanks!

Comments

Sign In or Register to comment.