Obtain the date of this week, next week, and last week based on the current time.

Source: Internet
Author: User

Click the button to change the week and obtain the specific date of the week, last week, and next week.

Some online methods are used for reference.

                           DateTime beginDate = getWeekUpOfDate(DateTime.Now, DayOfWeek.Monday, );         DateTime endDate = getWeekUpOfDate(DateTime.Now, DayOfWeek.Sunday, );                               DateTime getWeekUpOfDate(DateTime dt, DayOfWeek weekday,  wd1 = ( wd2 = ( wd2 == wd1 ? dt.AddDays( * Number) : dt.AddDays( * Number - wd2 + wd1);
Change weekly button event btnThisWeek_Click (beginDate = getWeekUpOfDate (DateTime. now, DayOfWeek. monday,); endDate = getWeekUpOfDate (DateTime. now, DayOfWeek. sunday,); btnLastWeek_Click (beginDate = getWeekUpOfDate (DateTime. now, DayOfWeek. monday,-); endDate = getWeekUpOfDate (DateTime. now, DayOfWeek. sunday,); btnNextWeek_Click (beginDate = getWeekUpOfDate (DateTime. now, DayOfWeek. monday,); endDate = getWeekUpOfDate (DateTime. now, DayOfWeek. sunday ,);
                                                     DateTime beginTime =             DateTime endTime =             DateTime[] times = GetDateTime(beginTime, endTime);              (times.Length >                    TextBox1.Text= times[].ToShortDateString();                    TextBox2.Text = times[].ToShortDateString();                    TextBox3.Text = times[].ToShortDateString();                    TextBox4.Text = times[].ToShortDateString();                    TextBox5.Text = times[].ToShortDateString();                    TextBox6.Text = times[].ToShortDateString();                    TextBox7.Text = times[].ToShortDateString();             }
                                                    List<DateTime> timeList =  List<DateTime>              (; beginTime <= endTime; beginTime = beginTime.AddDays())                 DateTime[] times =                      }

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.