DateTime convertion Error

B

B.N.Prabhu

hi,

I am having a DataTable which one column is in string format now i want to
change that one to DataTime. I don't know whether its in datetime format or
not i have to check if it is in DateTime Format some times it may in normal
string not a DateTime. If it is in any one of the DateTime format then i have
to change it as a Specfic format as "21-03-2005 11:34" using C#.Net.

If its not in DateTime format then i should give a message.

txt3.Text = txt3.Text.Replace("AM","");
txt3.Text = txt3.Text.Replace("PM","");
string strDateTime = txt3.Text.Trim();
DateTime dtConvert = DateTime.Parse(strDateTime);

// Format to 14-05-2006
string strConvert = dtConvert.ToString("dd-MM-yyyy");

I used this type but i am getting error as "String is not in a correct format"

I don't know what to do. any one please help.
 
C

Cindy M.

Hi =?Utf-8?B?Qi5OLlByYWJodQ==?=,

For the life of me, I can't figure out why this question is in the
WORD.drawing.graphics newsgroup?
I am having a DataTable which one column is in string format now i want to
change that one to DataTime. I don't know whether its in datetime format or
not i have to check if it is in DateTime Format some times it may in normal
string not a DateTime. If it is in any one of the DateTime format then i have
to change it as a Specfic format as "21-03-2005 11:34" using C#.Net.

If its not in DateTime format then i should give a message.

txt3.Text = txt3.Text.Replace("AM","");
txt3.Text = txt3.Text.Replace("PM","");
string strDateTime = txt3.Text.Trim();
DateTime dtConvert = DateTime.Parse(strDateTime);

// Format to 14-05-2006
string strConvert = dtConvert.ToString("dd-MM-yyyy");

I used this type but i am getting error as "String is not in a correct format"

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top