On 2015-03-02, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > greymausg wrote: > >> I have a csv file, the first item on a line is the date in the format >> 2015-03-02 I try to get that as a date by date(row[0]), but it barfs, >> replying "Expecting an integer". (I am really trying to get the offset >> in weeks from that date to today()) > > What is "date"? Where does it come from? > > If it is your own function, then we cannot help you unless you show us the > code for it. > > If you mean the standard library date, then you should say so. > > > py> from datetime import datetime > py> today = datetime.today() > py> astring = "2014-12-27" > py> another_day = datetime.strptime(astring, "%Y-%m-%d") > py> difference = today - another_day > py> difference.days > 65 > py> difference.days/7 # weeks > 9.285714285714286 > >
Standard datetime.date, if it were not, I would have written. Will try, thanks for the info. -- greymaus . . ... -- https://mail.python.org/mailman/listinfo/python-list