hi guys, i have a textbox that displays date in format,for eg:March,20,2008.Then i need to get total days n march in year 2008.Can anybody help
From stackoverflow
-
int year = DateTime.Now.Year; int month = DateTime.Now.Month; int numDays = DateTime.DaysInMonth(year, month);John Nolan : beat by 2 seconds! -
Use DataTime.DaysInMonth()
http://msdn.microsoft.com/en-us/library/system.datetime.daysinmonth(VS.71).aspx
-
You can use the DaysInMonth function
e.g.
Date.DaysInMonth(2008, 3)Obviously, you'll have to pass the year and month to the function
-
Remember to use the date they entered. VB Code:
dim enteredDate as DateTime = cdate(txtDateBox.text) dim daysInMonth as Int = DateTime.DaysInMonth(enteredDate.year,enteredDate.month)
0 comments:
Post a Comment