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


Groups > comp.lang.python > #32934 > unrolled thread

Re: get weekday as week number in a month

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2012-11-08 00:23 -0700
Last post2012-11-08 00:23 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#32934 — Re: get weekday as week number in a month

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-11-08 00:23 -0700
SubjectRe: get weekday as week number in a month
Message-ID<mailman.3423.1352359425.27098.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web