Tech Blog‎ > ‎

VB.NET - Format DateTime With Milliseconds

posted Jan 27, 2010, 12:07 PM by Victor Zakharov   [ updated Jul 28, 2010, 8:55 AM ]
Despite what people are saying on the net, you do not need to write your own method to include milliseconds when formatting DateTime object. To achieve this, you can use “f”. For example, if you want to include thousands of a second (i.e. milliseconds), you can write something like this:


You can set the fractional part to include up to 7 digits:


If you try more, it will raise an exception. Luckily, in basic scenarios, you do not need that.