How do you format the date time to just date?

For example, this is what I retrieved from the database: 12/31/2008 12:00:00 AM, but I just want to show the date and no time.


Either use one of the standard date and time format strings which only specifies the date (e.g. "D" or "d"), or a custom date and time format string which only uses the date parts (e.g. "yyyy/MM/dd").

  • 12
    for example: DateTime.Now.ToString("d") – schmoopy Dec 17 '08 at 19:17
  • This works if you want a string result. If you want a date result, see madcolor's response below. I mean I guess you could just cast the string back to a date, but it's an extra step. – Aaron May 14 '14 at 14:51
  • @Aaron: What do you think FormatDateTime (in madcolor's answer) returns? The OP wants a string - that's what "format" means, and that's what both my result and FormatDateTime give. The difference is that using ToString is a more .NET-idiomatic approach, which doesn't require Microsoft.VisualBasic.dll. – Jon Skeet May 14 '14 at 14:53

FormatDateTime(Now, DateFormat.ShortDate)

  • 1
    No clue why this doesn't have more upvotes. Maybe people don't realize you can replace the Now with any date? Either way, good on you. upvoted. – Aaron May 14 '14 at 14:48

I almost always use the standard formating ShortDateString, because I want the user to be in control of the actual output of the date.


   Dim d As DateTime = Now


Wednesday, December 10, 2008

Note that these results will vary depending on the culture settings on your computer.


Format datetime to short date string and convert back to date


Or use short date string


Or, if for some reason you don't like any of the more sensible answers, just discard everything to the right of (and including) the space.

  • Could it be possible that a user could set up a space as their date separation character? If so then your suggestion would fail - unlikely as it might be. – Matt Wilko Mar 14 '12 at 16:45
  • 1
    Not familiar enough with VB.Net to say. Other frameworks & databases I've used always return the date in the same format regardless of what the OS settings are, and it's up to the app to translate. – Brian Knoblauch Mar 14 '12 at 19:06

Your Answer

