I want to count number of days using two datetime picker. Please take a look the picture below.
image1
But, if you can see the image below., they counting number of days PER DAY,
image2
that’s why the total number of days display is equal to 2 days.
image3
instead of one day, because of time.
image4
I have a code to count number of day
DateTime dt1 = dtpckerPickupDate.Value;
DateTime dt2 = dtpckerReturnDate.Value;
TimeSpan t = dt2 - dt1;
double dDays = t.TotalDays;
//int days = Convert.ToInt32(dDays);
int PlusOneDay = Convert.ToInt32(dDays + 1);//if counting included today
txtNumOfDays.Text = PlusOneDay.ToString() + " Days";
New contributor
user26149487 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.