Resources » Code Snippets » C# Syntax

To to find date difference in C#


Posted Date: 05-Mar-2008  Last Updated:   Category: C# Syntax    
Author: Member Level: Gold    Points: 10



This code sample shows how to find the difference between two dates in C#



DateTime dt = Convert.ToDateTime("01/01/2008");
DateTime dt1 = Convert.ToDateTime("05/03/2008");
TimeSpan ts = dt.Subtract(dt1);
int day = ts.Days;
textBox1.Text = day.ToString();



Did you like this resource? Share it with your friends and show your love!

Responses to "To to find date difference in C#"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Program
    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India