Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 814003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:27:06+00:00 2026-05-15T01:27:06+00:00

I am looking to do something really simple. Merely convert a string, such as

  • 0

I am looking to do something really simple. Merely convert a string, such as ‘december’ into something I can use with MySQL (such as ’12’).

At the moment I use a dict,

month_map = {
    'december': '12',
    'november': '11',
    'october': '10',
    'september': '09',
    'august': '08',
    'july': '07',
    'june': '06',
    'may': '05',
    'april': '04',
    'march': '03',
    'february': '02',
    'january': '01'
}

and then month_map.get('december').

Does any function already exist within the standard python modules that can achieve this? Apologies if this has already been asked.. the questions I have found using search seem a little different.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:27:07+00:00Added an answer on May 15, 2026 at 1:27 am

    It’s locale-dependent, but you can accomplish this with strptime:

    >>> import datetime
    >>> datetime.datetime.strptime('december', '%B').month
    12
    >>> datetime.datetime.strptime('january', '%B').month
    1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do something really simple, convert a datetime object three days into
Can someone recommend a simple c# code generator. I just looking something with methods
I'm really looking for something very similar to the way SO is setup where
I am looking for a really simple database implementation; basically one with no complex
I am trying to do something really simple, but somehow not getting the direction.
Program I'm making has a simple configuration file looking something like this. @overlays =
I feel like I must be doing something really stupid. What can I do
What is the simplest ORM implementation around for PHP? I'm looking for something really
This should be really simple. If I have a String like this: ../Test?/sample*.txt then
This should be really simple, but I can't seem to figure out what to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.