DateTime Conversion problem

Posted by kbm5evm-16703 under ASP.NET on 8/27/2012 | Points: 10 | Views : 991 | Status : [Member] | Replies : 2
Hi..

I exported .ics(calendar) file from google calendar. Now i want to insert those events into database. while inserting we need to convert start time and end time to normal time.but i cant able to do that. how to convert it to Datetime format?

time is in this format "20120726T063000Z\r"

i need 07/26/2012 12:00:00PM

Thanks in advance




Responses

Posted by: Naraayanan on: 9/25/2012 [Member] Starter | Points: 25

Up
0
Down
Hi
Try this Code,

   static string splitstring(string str,int firstIndex, int endingIndex)

{
string firstFourCharacters;
return firstFourCharacters = str.Substring(firstIndex, endingIndex);
}

private void button1_Click(object sender, EventArgs e)
{
string datetime = "20120726T063000Z\r" ;
string year = splitstring(datetime, 0, 4);
string month = splitstring(datetime, 4, 2);
string date = splitstring(datetime, 6, 2);
string dt = month + "/" + date + "/" + year + " " + "12:00:00PM ";
MessageBox.Show(dt);

}



Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

kbm5evm-16703, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 9/25/2012 [Member] Starter | Points: 25

Up
0
Down
DateTime dt = DateTime.Now.Date;
protected void Page_Load(object sender, EventArgs e)
{

txtDate.Text=dt.ToShortDateString();
}

kbm5evm-16703, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response