Convert a date and time in a string to customize format

Hi,

I have a string that looks like this:

"14-11-2011 15:30"

I want to change this to:

14 (14:30) <---display only the daynumber and the time

How can I to this?
Peter

LVL 1
peterkiersAsked:
Who is Participating?
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
See the attached picture.
0017.jpg
0
 
BardobraveCommented:
I supose you have the DateTime value in any place of your code (and build your current string with it).

Then is easy to do what you want:

DateVariable.MonthDay + "(" + DateVariable.Hours + ":" + DateVariable.Minuets + ")"

If you haven't the DateTime variable you'll need to cast your current value to DateTime first.
Play around with Convert.ToDateTime() and DateTime.Parse() to see if your current string is correctly casted to a DateTime value.
0
 
peterkiersAuthor Commented:
Thanks AndyAinscow.
500 points are comming to you...

Greetings,

Peter Kiers
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.

All Courses

From novice to tech pro — start learning today.