Last active
December 31, 2015 06:48
-
-
Save patHyatt/7949513 to your computer and use it in GitHub Desktop.
Code to obtain last Wednesday of month
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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