C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET WebForms »

Using timespan class


Posted Date: 18 Oct 2009    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: krishnavenikaladiMember Level: Gold    
Rating: 1 out of 5Points: 3



time span class is used to calculte the no of days and no of hours,minutes,seconds and also milliseconds between specified dates.



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

DateTime adate = DateTime.Parse("6/23/09");
DateTime bdate = DateTime.Parse("7/23/09");

TimeSpan ts = new TimeSpan(bdate.Ticks - adate.Ticks);
Response.Write(ts.TotalDays.ToString() + "
");
Response.Write(ts.TotalHours.ToString() + ":" + ts.TotalMinutes.ToString() + ":" + ts.TotalSeconds.ToString ());


}

}





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Timespanclass  .  Timespan  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Enumerations Diff Between VB.NET & C#.NET
Previous Resource: Maintain Checked State for CheckBoxList in ASP.NET
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use