Get Last Date of Given Month and Year in c# -


i want c# code getting last date of week given month , year.

suppose given month 1 , year 2016 method should return me

--01/02/2016 --01/09/2016 --01/16/2016 --01/23/2016 --01/30/2016 --02/06/2016 

public static datetime getlastdateofweek(int yr, int mnth, int week) { datetime dt = new datetime(yr, mnth, 1); datetime newdate = new datetime(); if (dt.dayofweek == dayofweek.monday) { newdate = dt.adddays(((week - 1) * 7) + 5); } else { newdate = dt.adddays((8 - (int)dt.dayofweek) % 7 + ((week - 2) * 7) + 5); } return newdate; }


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -