get weekday as week number in a month

Ian Kelly ian.g.kelly at
Thu Nov 8 08:23:07 CET 2012

On Thu, Nov 8, 2012 at 12:09 AM, Nikhil Verma <varma.nikhil22 at> wrote:
> What i want to know is if i convert it to
> date_object = datetime.strptime(' Friday November 9 2012 11:30PM', '%u %B %d
> %Y %I:%M%p' )
> It is giving me ValueError saying u is unsupported directive !

Use '%A' to match 'Friday', not '%u'.  The full list of directives can
be found at:

> How can i get weekday as week number ?

Is this what you're looking for?

>>> datetime.strptime('Friday November 9 2012 11:30PM', '%A %B %d %Y %I:%M%p').weekday()

More information about the Python-list mailing list