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 8737163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:27:16+00:00 2026-06-13T10:27:16+00:00

Possible Duplicate: Python Question: Year and Day of Year to date? Is there a

  • 0

Possible Duplicate:
Python Question: Year and Day of Year to date?

Is there a method in Python to figure out which month a certain day of the year is in, e.g. today is day 299 (October 26th). I would like to figure out, that day 299 is in month 10 (to compile the string to set the Linux system time).
How can I do this?

  • 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-06-13T10:27:18+00:00Added an answer on June 13, 2026 at 10:27 am
    print (datetime.datetime(2012,1,1) + datetime.timedelta(days=299)).month
    

    Here’s a little more usable version that returns both the month and day:

    def get_month_day(year, day, one_based=False):
        if one_based:  # if Jan 1st is 1 instead of 0
            day -= 1
        dt = datetime.datetime(year, 1, 1) + datetime.timedelta(days=day)
        return dt.month, dt.day
    
    >>> get_month_day(2012, 299)
    (10, 26)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why there are no ++ and — operators in Python? This question
Possible Duplicate: How to find out the arity of a method in Python For
Possible Duplicate: The Python yield keyword explained Okay, I've probably phrased the question badly
Possible Duplicate: Python conditional assignment operator Apologies for such a simple question, but googling
Possible Duplicate: Learn Python the Hard Way Exercise 17 Extra Question(S) In this exercise
Possible Duplicate: How do you generate dynamic (parameterized) unit tests in Python? Is there
Possible Duplicate: Python list confusion I've got one little question about Python lists: Why
Possible Duplicate: In what order does python display dictionary keys? There was this very
Possible Duplicate: How to get line count cheaply in Python? Good day. i have
Possible Duplicate: python import question What is the difference between importing a Python file

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.