Solved

DateTime.ToString problem

Posted on 2008-06-18
3
454 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

752 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