Date and Time format strings in .NET – Introduction

One of the most common misunderstandings I see on StackOverflow regarding the DateTime structure is the difference between the value of a DateTime instance and how it is displayed.

A DateTime instance (say one representing midnight of March 26th 2011) has an internal representation that has no specific formatting – it is not something that will make sense to any human being in that form (this post is not about what exactly that representation is).

What this means is that every time you see a value for a DateTime instance, you are seeing this internal value after it has been formatted for human eyes.

How this formatted value comes to be is the subject of this blog series, starting with this introduction.

In future posts I will discuss the roles of IFormatProvider and format strings, Cultures and the Regional settings.

2 Responses

  1. Marc Scheuner (marc_s) 20/11/2011 / 21:04

    This holds especially true for DATETIME in SQL Server, too – lots of devs seems to be under the impression, the DATETIME is stored in some default string-based format, like MM/DD/YYYY or something…. Looking forward to your series of posts!

  2. Oded Coster 26/11/2011 / 21:10

    Thanks for the kind words – I am new at blogging and comments like this give me encouragement to go on, despite my belief that I don’t have much to contribute…

    Please let me know what you think about the series as it comes along – any and all suggestions would be welcome.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>