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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:15:50+00:00 2026-05-24T06:15:50+00:00

How can I get the start and end date of a given year (int),

  • 0

How can I get the start and end date of a given year (int), given month (int), and given week (int) { example Year : 2011 Month: 07 week: 04 } in c# 4.0? Thanks in advance.

The Start Date of the Year 2011 Month 07 and the week number of the month is 04.

  • 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-24T06:15:51+00:00Added an answer on May 24, 2026 at 6:15 am

    Google is your friend.

    Months:

    public DateTime FirstDayOfMonthFromDateTime(DateTime dateTime)
    {
       return new DateTime(dateTime.Year, dateTime.Month, 1);
    }
    
    
    public DateTime LastDayOfMonthFromDateTime(DateTime dateTime)
    {
       DateTime firstDayOfTheMonth = new DateTime(dateTime.Year, dateTime.Month, 1);
       return firstDayOfTheMonth.AddMonths(1).AddDays(-1);
    }
    

    You can do something similar for years:

       DateTime time = new DateTime(2011,1,1);
       time.AddYears(1).AddDays(-1);
    

    And week needs to use the CultureInfo.FirstDay (or whatever you want to set as the first day of a week, in some countries it’s Monday, sometimes it’s Sunday).

    /// <summary>
        /// Returns the first day of the week that the specified
        /// date is in using the current culture. 
        /// </summary>
        public static DateTime GetFirstDayOfWeek(DateTime dayInWeek)
        {
            CultureInfo defaultCultureInfo = CultureInfo.CurrentCulture;
            return GetFirstDateOfWeek(dayInWeek, defaultCultureInfo);
        }
    
        /// <summary>
        /// Returns the first day of the week that the specified date 
        /// is in. 
        /// </summary>
        public static DateTime GetFirstDayOfWeek(DateTime dayInWeek, CultureInfo cultureInfo)
        {
            DayOfWeek firstDay = cultureInfo.DateTimeFormat.FirstDayOfWeek;
            DateTime firstDayInWeek = dayInWeek.Date;
            while (firstDayInWeek.DayOfWeek != firstDay)
                firstDayInWeek = firstDayInWeek.AddDays(-1);
    
            return firstDayInWeek;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get last year's start and end date using PHP code? Is
Using PHP how can I get week's start date and end date from any
How can i get the start and end sectors of the partitions of my
I am trying to the get start and end date of a jira project
How can I get this to compile? The error is when I start using
I've been trying to get django set up so I can start learning it.
A table exists in Microsoft SQL Server with record ID, Start Date, End Date
My goal is to return a start and end date having same value in
Given a date I can access the appropriate element in a zoo vector. For
I have tried the example given in stack overflow how to get a list

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.