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
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Calculate difference between two Dates
Pintoo Yadav
Sep 12
2015
Code
1.1
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
public
void
date() {
Datetime startdate;
Datetime enddate;
Timespan remaindate;
startdate = DateTime.Parse(txtstartdate.Text).Date;
enddate = DateTime.Parse(txtenddate.Text).Date;
Remaindate = enddate - startdate;
if
(remaindate !=
null
) {
lblmsg.Text =
"you have left with "
+ Remaindate.TotalDays +
"days."
;
}
else
{
lblmsg.Text =
"correct your code again."
;
}
}
protected
void
btncal_Click(
object
sender, EventArgs e) {
date();
}
calculate difference
between two dates