Solved

DateTime.ToString problem

Posted on 2008-06-18
3
423 Views
Last Modified: 2013-12-16
i'm reading in a datetime from a database and then outputting to another text file.
However, the following code appears to display a date incorrect...such as: 18 00 2008
myCurrentLine.Append(((DateTime)this.m_Headers.Rows[this.m_HeadersProcessed + i]["Order Date"]).ToString("dd mm yyyy"));

If i leave it without formatting:
myCurrentLine.Append(((DateTime)this.m_Headers.Rows[this.m_HeadersProcessed + i]["Order Date"]).ToString());
i get the following result: 18/06/2008 00:00:000

What i need to display is just: 18 06 2008

any ideas why its setting the month incorrectly with this code:
myCurrentLine.Append(((DateTime)this.m_Headers.Rows[this.m_HeadersProcessed + i]["Order Date"]).ToString("dd mm yyyy"));
0
Comment
Question by:zell71
3 Comments
 
LVL 6

Accepted Solution

by:
Sh4d1 earned 350 total points
ID: 21812908
Use this:
myCurrentLine.Append(((DateTime)this.m_Headers.Rows[this.m_HeadersProcessed + i]["Order Date"]).ToString("dd MM yyyy"));

Open in new window

0
 
LVL 7

Assisted Solution

by:orcic
orcic earned 150 total points
ID: 21812941
Just a short explanation:
mm is used for minutes
MM is for used for month
0
 
LVL 6

Author Closing Comment

by:zell71
ID: 31468343
Due to the time difference..it would be harsh to just award points to the first answer as you both probably posted at the same time.
both correct! cheers guys
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now