n case of date time calculation from front end we need to find out the days difference between two given dates by user. Dates may come from dtpicker or from calendar control whatever we will use asp.net built in subtract method to identified the number of days or date difference between two dates. In this article i will show you to identify datediff between two dates in C# front end Language.
protected void Page_Load(object sender, EventArgs e) { DateTime dTFrom; DateTime dTo; string sFrom = "April 30, 2010"; string sTo = "May 08, 2010"; if (DateTime.TryParse(sFrom, out dTFrom) && DateTime.TryParse(sTo, out dTo)) { TimeSpan TS = dTo.Subtract(dTFrom); int days_Diff = TS.Days; Response.Write("Day diference between two dates: "+days_Diff.ToString()); } }
No comments:
Post a Comment