Solved

DateTime.ToString problem

Posted on 2008-06-18
3
458 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

626 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