Getting no. of weeks in a specified months.

Posted by Vishalneeraj-24503 under Visual Studio category on | Points: 40 | Views : 1089
Here is the code,
public int Get_No_Of_Weeks(DateTime FromDate, DateTime ToDate)
int No_Of_Days = ToDate.Subtract(FromDate).Days;
int no_of_weeks = (int)No_Of_Days / 7;
return (int)No_Of_Days / 7;
Response.Write(Get_No_Of_Weeks(DateTime.Now, DateTime.Now.AddMonths(4)))

Here,we will calculate no of weeks in between May and September so number of weeks would be 17

Comments or Responses

Login to post response