Solved

How to convert a DateTime value to a formatted string

Posted on 2009-05-06
4
662 Views
Last Modified: 2012-05-06
I have a DateTime value that needs to be converted to a formatted string.

DateTime dteChangeDate;

dteChangeDate = DateTime.Parse(calCalendar.SelectedDate.ToString());

Returns {5/4/2009 12:00:00 AM}

How do I convert this to the following string using C#:

string strChangeDate;

strChangeDate = a function or method of dteChangeDate that returns "20090504" ???

Thanks,
0
Comment
Question by:Dovberman
  • 2
4 Comments
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 24315490
0
 
LVL 9

Accepted Solution

by:
tetorvik earned 125 total points
ID: 24315524
dteChangeDate .ToString("yyyyMMdd");
0
 
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 125 total points
ID: 24315546
strChangeDate.ToString("yyyyMMdd")
0
 

Author Closing Comment

by:Dovberman
ID: 31578487
This works well. Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSRS ReportViewer report timeout 7 100
Tool Box 2 34
Two different visual studio versions 3 21
C# MVC and a global static factory that never dies 4 45
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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

12 Experts available now in Live!

Get 1:1 Help Now