Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #32934

Re: get weekday as week number in a month

References <CABgq=Fz=NpZ8P8AtMmn=xAR-R1SZ1u-OL-M5iA8R5O9O6FBdVQ@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2012-11-08 00:23 -0700
Subject Re: get weekday as week number in a month
Newsgroups comp.lang.python
Message-ID <mailman.3423.1352359425.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Nov 8, 2012 at 12:09 AM, Nikhil Verma <varma.nikhil22@gmail.com> 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:

http://docs.python.org/2/library/time.html#time.strftime

> 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()
4

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: get weekday as week number in a month Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-08 00:23 -0700

csiph-web