• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 680
  • Last Modified:

How to convert a DateTime value to a formatted string

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
Dovberman
Asked:
Dovberman
  • 2
2 Solutions
 
Kevin CrossChief Technology OfficerCommented:
0
 
tetorvikCommented:
dteChangeDate .ToString("yyyyMMdd");
0
 
Kevin CrossChief Technology OfficerCommented:
strChangeDate.ToString("yyyyMMdd")
0
 
DovbermanAuthor Commented:
This works well. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now