Re: get weekday as week number in a month

Discussion in 'Python' started by Ian Kelly, Nov 8, 2012.

  1. Ian Kelly

    Ian Kelly Guest

    On Thu, Nov 8, 2012 at 12:09 AM, Nikhil Verma <> 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
    Ian Kelly, Nov 8, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    3
    Views:
    1,840
    Alexandre
    Dec 22, 2003
  2. Guest
    Replies:
    3
    Views:
    522
    Alexandre
    Dec 22, 2003
  3. Guest
    Replies:
    3
    Views:
    1,087
    Alexandre
    Dec 22, 2003
  4. David Morgan
    Replies:
    2
    Views:
    153
    Manohar Kamath [MVP]
    Feb 24, 2004
  5. SimonC
    Replies:
    13
    Views:
    334
    Dr John Stockton
    Jan 4, 2005
Loading...

Share This Page