Format a date?

Netnoobie

Regular
Joined
Feb 6, 2003
Messages
94
Location
Philadelphia
Hello, I'm trying to format a date with no success. What I need to do is to take a date no matter how it comes in and save it to a table as YYYYMMDD. Now, I'll take even getting it to MM/DD/YYYY and then splitting it up if need be. But the issue I'm having is when someone inputs 2/24/03 for instance, doing a ToShortDateString gives me 2/24/2003. I need it 02/24/2003 so that there is padding in the MM and DD. Is there a way to format like this? In VB6 I would just tell it the format I wanted and that was it. But I can't seem to find that functionality in .NET or anything that gets me close to what I need.

Any good date formatting resource that Google may have missed? Many thanks.
 
Visual Basic:
Dim dt As DateTime = DateTime.Now
Dim dtString As String = dt.ToString("yyyyMMdd")

[mshelp]ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemDateTimeClassToStringTopic3.htm[/mshelp]
 
Back
Top