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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:33:06+00:00 2026-05-28T14:33:06+00:00

Given datetime.datetime.now(), how do I get this week’s Monday – Sunday and then the

  • 0

Given datetime.datetime.now(), how do I get this week’s Monday – Sunday and then the same Monday – Sunday for last year, considering leap years?

One idea I had was to get the timedelta for -365 days and then find the nearest Monday or Sunday. I’m sure there is a better way.

Edit: I don’t mind using datetuil, if there is something in there that’d make this easier.

  • 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-28T14:33:07+00:00Added an answer on May 28, 2026 at 2:33 pm

    If using dateutil is not a problem, just use it 🙂

    The relativedelta is the object you need
    Here you will be able to substract one year to the current date.

    from datetime import *
    from dateutil.relativedelta import *
    NOW = datetime.now()
    last_monday = NOW+relativedelta(years=-1, weekday=MO)
    last_sunday = NOW+relativedelta(years=-1, weekday=SU)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this: Public Sub timReminder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) If DateTime.Now()
I have this enum: public enum TimePeriod { Day = DateTime.Now.AddDays(-1), Week = DateTime.Now.AddDays(-7),
Given a domain object: class BirthdayDomain { public DateTime Birthday { get; set; }
datetime.datetime.utcnow() Why does this datetime not have any timezone info given that it is
As the title says, given the year and the week number, how do I
The Python datetime.isocalendar() method returns a tuple (ISO_year, ISO_week_number, ISO_weekday) for the given datetime
Given a DateTime representing a person's birthday, how do I calculate their age in
Given a datetime.time value in Python, is there a standard way to add an
In MS SQL 2000 and 2005, given a datetime such as '2008-09-25 12:34:56' what
Given a specific DateTime value, how do I display relative time, like: 2 hours

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.