Solved

How to convert a DateTime value to a formatted string

Posted on 2009-05-06
4
661 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

20 Experts available now in Live!

Get 1:1 Help Now