Dear Brother's
Do you have any idea that how can i get total days of current month. current month is feb than totalday must be 28 and if current mont is marach than totalday must be 31.. I need this function. please help me reagrding this problem.. thanks in advance
best regrads
Waqar Hussain Laghari
Praveen KumarPosted Mar 31, 2009, 6:02 AM
int
noofdays = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);Jiyaul MustaphaPosted Aug 17, 2019, 5:48 AM
vira trivediPosted Mar 16, 2010, 7:36 AM
waqar laghariPosted Mar 31, 2009, 7:35 AM
Thank you very much.. I got result using following function.
int days = DateTime.DaysInMonth(CurrentY, CurrentM);Again thanks for all replies..
Best regards
Waqar Hussain laghari
waqar laghariPosted Mar 31, 2009, 7:19 AM
Thanks brothers.
int numDays = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
but this function actually calcuate the current month's days. But brother i want to find out the cunrentMonth -1 month. do you have any idea about it..
Thanks
Best regards
Waqar Hussain Laghari
vivek kulkarniPosted Mar 31, 2009, 6:14 AM
Hi,
Here is how you can write a function. Use an arralist to define all the days in month one after the other upto 12.
arr.Add(31);
arr.Add(28);
arr.Add(31);
arr.Add(30);
.......................
you can directly access the days by using the index in the array square bracket.
Here is a function to calculate the leap year for getting the days in feb.
private bool CheckLeapYear ( int year )
{
bool leapYear = false;
leapYear = ( ( ( year % 4 ) == 0 ) && ( ( year % 100 ) != 0 ) || ( ( year % 400 ) == 0 ) );
if ( leapYear.Equals ( true ) )
return true;
else
return false;
}
Thank you
RobertPosted Mar 31, 2009, 6:10 AM
Hi,
This should work
int
numDays = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);Best regards
Robert