Blog on software engineering
How to determine the datetime of the first day of the week

How to determine the datetime of the first day of the week

If you want to determine the datetime of the first day of the week, you can use the following code:

// Get the first day of the week
DayOfWeek firstDay = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek; 
DateTime firstDayOfWeekDateTime = DateTime.Now;
while (firstDayOfWeekDateTime.DayOfWeek != firstDay)
{
    firstDayOfWeekDateTime = firstDayOfWeekDateTime.AddDays(-1);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.