Get Day of Week - C#

Get Day of Week - C#

code snippet

c#
public static DateTime getDayOfWeek(DateTime dt, DayOfWeek idayOfWeek)
    {
        int diff = dt.DayOfWeek - idayOfWeek;
        if (diff < 0)
        {
            diff += 7;
        }
        return dt.AddDays(-1 * diff).Date;
    }

"Perfection is not attainable, but if we chase perfection we can catch excellence"

Contact me!

Have questions? Feel free to use the form or send me an email with any questions.

I will be responsive to your requests and your questions.