Welcome to my blog.

Post on this blog are my experience which I like to share. This blog is completely about sharing my experience and solving others query. So my humble request would be share you queries to me, who knows... maybe I can come up with a solution...
It is good know :-)

Use my contact details below to get directly in touch with me.
Gmail: nadarmuthukumar1987@gmail.com
Yahoo: nadarmuthukumar@yahoo.co.in

Apart from above people can share their queries on programming related stuff also. As me myself a programmer ;-)

Get last thursday of a month in C#

int Monthly = 1;
DateTime StartDate = new DateTime(2012, 01, 01);
DateTime EndDate = new DateTime(2012, 10, 01);
for (DateTime i = StartDate; i < EndDate; i = i.AddMonths(Monthly))
    const int Thursday = 4;
    const int DayDiff = 7 - Thursday;
    //This will give me last day of month
    int Day = DateTime.DaysInMonth(i.Year, i.Month);
    //This will return any value from "0-7" where 0 is sunday.
    int DayOfWeek = (int)new DateTime(i.Year, i.Month, Day).DayOfWeek;
    DateTime _dtNew = new DateTime(i.Year, i.Month, Day).AddDays(-((DayOfWeek < Thursday) ? (DayOfWeek + DayDiff) : (DayOfWeek - Thursday)));
    Response.Write(_dtNew.ToString("dd-MMM-yyyy") + "
"); }
Reference: Muthukumar (http://nadarmuthukumar.blogspot.in)
Hope you liked this and let me know your thoughts on post through your comments :)

Twitter Delicious Facebook Digg Stumbleupon Favorites More