C#
  Home arrow C# arrow Working with Dates and Times in C#
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

Working with Dates and Times in C#
By: Barzan "Tony" Antal
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2008-12-30

    Table of Contents:
  • Working with Dates and Times in C#
  • Brief Overview
  • Putting DateTime into Action
  • Final Words

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with Dates and Times in C#


    (Page 1 of 4 )

    Every software engineer can testify that all kinds of projects, regardless of their purpose or how simple the requirements seem to be, deal with dates and mostly times. Fortunately, C# has built-in methods and properties that make our lives much easier. In this article we will present some of the most common techniques to manage and work with date and time variables.

    Before we begin, you should be also informed that there are numerous other how-to articles covering various topics from the Windows registry up to regular expressions, lossless image conversion and resizing, working with collections, and more, published already here at ASP Free under the C# category. Be sure to check those out.

    At the beginning of this article we will introduce the foundation concepts that must be understood in order to learn the rest. We will present the DateTime structure located in the System namespace. Moving on, its properties, methods, and constructors will also be explained thoroughly and also illustrated with examples (such as code samples with output).

    This guide assumes familiarity with the C# syntax, but not with dates/times. It does not target professional coders, but rather those who are now learning how to code in C#. It's a great language to begin with; there's plenty of documentation along with proactive communities on various forums.

    Thus, if you are ready to learn the basics of date and time handling in C# that are going to serve as a solid ground foundation to your further researches, let's begin! We are going to focus on explaining how to do the most necessary tasks such as assigning date and time, how to compare them with each other, various format conversions, and ultimately specific value extraction (such as part of a date).

    More C# Articles
    More By Barzan "Tony" Antal


       · Thank you for reading this article. In this part I've shown you how to work with...
       · The information was useful but when i put your code in my main method, I got errors....
     

    C# ARTICLES

    - Coding a CRC-Generating Algorithm in C
    - Cyclic Redundancy Check
    - Handling Methods and Functions
    - Destroying Objects in C#
    - Creating Objects in C-Sharp
    - Classes and Objects
    - Programming Languages: Managed versus Native
    - LINQ-to-MySQL with DbLinq in C#
    - Working with Dates and Times in C#
    - Generics, Dictionaries, and More
    - More About Generics
    - Working with C# Collections
    - Generics
    - C# and XML
    - Pointers and Arrays in C#





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek