By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,567 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

How do I format DateTime as mmddyyyy

P: n/a
I am trying to format a DateTime object as mmddyyyy and NOT mm/dd/yyyy. What
is the easiest way to do this?
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Never mind... found the pattern ("MMddyyyy").

(I was using "mmddyyyy")
Nov 16 '05 #2

P: n/a
Use the ToString overload and pass the format required in it.

Eg:
dt.ToString("mmddyyyy"); or
dt.ToString("dd-mm-yy");
--
Rakesh Rajan
"Jack" wrote:
I am trying to format a DateTime object as mmddyyyy and NOT mm/dd/yyyy. What
is the easiest way to do this?

Nov 16 '05 #3

P: n/a
That is what I was attempting but found a nuance... mmddyyyy formats as
minute, day, month. The correct format is MMddyyyy.

"Rakesh Rajan" <Ra*********@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
Use the ToString overload and pass the format required in it.

Eg:
dt.ToString("mmddyyyy"); or
dt.ToString("dd-mm-yy");
--
Rakesh Rajan
"Jack" wrote:
I am trying to format a DateTime object as mmddyyyy and NOT mm/dd/yyyy. What is the easiest way to do this?

Nov 16 '05 #4

P: n/a
Jack wrote:
I am trying to format a DateTime object as mmddyyyy and NOT mm/dd/yyyy. What
is the easiest way to do this?

DateTime dt = DateTime.Now;

System.Console.WriteLine(string.Format("{0,2:00}{1 ,2:00}{2,04:0000}",dt.Day,dt.Month,dt.Year));
Nov 16 '05 #5

P: n/a
anon <a@a.com> wrote:
Jack wrote:
I am trying to format a DateTime object as mmddyyyy and NOT mm/dd/yyyy. What
is the easiest way to do this?

DateTime dt = DateTime.Now;

System.Console.WriteLine(string.Format("{0,2:00}{1 ,2:00}{2,04:0000}",dt.Day,dt.Month,dt.Year));


or alternatvely:

dt.ToString("MMddyyyy");

/J\
Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.