Solved

How to convert a DateTime value to a formatted string

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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 …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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