Search code examples
python-2.7xlrd

How to get week number?


Here its printing only the current week number for all dates in the excel sheet i need to print week number, corresponding week number for each dates in sheet which i stored it in list,how to get week number for each dates which is stored in list type?

 print datetime.datetime(2015,9,03).isocalendar()[1]

Solution

  • The problem is that the constructor for the datetime type expects an integer for the year. See https://docs.python.org/2/library/datetime.html#datetime.datetime for the syntax

    Depending on what the datatype of your datelist[0] object is, you will need to extract date components from it