TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
B M Suchitra
NA
507
418.1k
Problem converting string to datetime format
Jan 9 2012 3:58 AM
Hi,
I am using calender extender for 2 textboxes allowing user to enter start and end date.. The format is "dd/MM/yyyy".. My code is as below for converting to datetime..
private int duration(string startdate, string enddate)
{
DateTime dt1= DateTime.Parse(startdate);
DateTime dt2= DateTime.Parse(enddate);
//dt1 = Convert.ToDateTime(txtstartdate.Text);
//dt2 = Convert.ToDateTime(txtenddate.Text);
TimeSpan ts = dt2.Subtract(dt1);
int days = ts.Days;
Session["days"] = days.ToString();
return days;
}
protected void txtenddate_TextChanged(object sender, EventArgs e)
{
int projectdays = duration(txtstartdate.Text, txtenddate.Text);
txtduration.Text = Convert.ToString(projectdays);
}
==================
When user selects the date from calender extender say todays date.9/1/2012
it is been taken as 1 september 2012
Reply
Answers (
15
)
How to create the Metaphone searching in asp.net code (C#)
Dear Techies, I wish u all a very Happy New Year.