Skip to content

Instantly share code, notes, and snippets.

@patHyatt
Last active December 31, 2015 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patHyatt/7949513 to your computer and use it in GitHub Desktop.
Save patHyatt/7949513 to your computer and use it in GitHub Desktop.
Code to obtain last Wednesday of month
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;
int lastDay = DateTime.DaysInMonth(year, month);
DateTime current = new DateTime(year, month, lastDay);
while (current.DayOfWeek != DayOfWeek.Wednesday)
current = current.AddDays(-1);
//current should have last wed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment