Get Date of the Monday in the Current Week


Please find code snippet for getting date of Monday in current week.

protected void Page_Load(object sender, EventArgs e)
    {
        DateTime FirstDayOfWeek = DateTime.Now;
        DayOfWeek WeekDay = FirstDayOfWeek.DayOfWeek;
        Culture = "en-GB";
        switch (WeekDay)
        {
            case DayOfWeek.Monday:
                break;
            case DayOfWeek.Tuesday:
                FirstDayOfWeek = FirstDayOfWeek.AddDays(-1);
                break;
            case DayOfWeek.Wednesday:
                FirstDayOfWeek = FirstDayOfWeek.AddDays(-2);
                break;
            case DayOfWeek.Thursday:
                FirstDayOfWeek = FirstDayOfWeek.AddDays(-3);
                break;
            case DayOfWeek.Friday:
                FirstDayOfWeek = FirstDayOfWeek.AddDays(-4);
                break;
            case DayOfWeek.Saturday:
                FirstDayOfWeek = FirstDayOfWeek.AddDays(-5);
                break;
            case DayOfWeek.Sunday:
                FirstDayOfWeek = FirstDayOfWeek.AddDays(-6);
                break;
 
        }
       string mondaydate = FirstDayOfWeek.ToString("dd/MM/yyyy");
       Response.Write(mondaydate);
     
    }
Advertisements

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s