Netnoobie Posted February 24, 2003 Posted February 24, 2003 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. Quote
*Gurus* Derek Stone Posted February 24, 2003 *Gurus* Posted February 24, 2003 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] Quote Posting Guidelines
bungpeng Posted February 26, 2003 Posted February 26, 2003 This .NET function is same with VB6 Format(myDate,"YYYYMM") Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.