Hello sir i want to calculate no oh houres like per day 4 houre and implement on calculattor like i will entre total no of houre is 44 and i will chose date 01/01/2017 then calculate end date is 11/01/2014 on calender how can do that plz help me....
protected void txt_startDate_TextChanged(object sender, EventArgs e)
{
String dateInString = txtnohr.Text;
DateTime r, r1;
string s = "", s1 = "";
DateTime startDate = DateTime.Parse(txt_startDate.Text);
int totalnoofhr, oneday = 4;
totalnoofhr = Convert.ToInt32(dateInString);
int count = 0;
for (int j = 0; j <= totalnoofhr; j++)
{
if (totalnoofhr != 0)
{
if (count == j)
{
s = startDate.AddDays(j).ToShortDateString();
totalnoofhr = totalnoofhr - oneday;
count = count + 1;
}
}
}
s1 = s;
lbl_show.Text = s1;
r1 = Convert.ToDateTime(s1);
s1 = r1.AddDays(1).ToShortDateString();
String myString = s1; // get value from text field
r = Convert.ToDateTime(myString);
String myString_new = r.ToString("yyyy-MM-dd"); // add myString_new to oracle
lbl_show.Text = myString_new;
}
18 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ankit SharmaPosted Sep 18, 2017, 4:26 AM
Sanjana KhalasiPosted Oct 12, 2017, 3:40 AM
Ankit SharmaPosted Sep 18, 2017, 4:46 AM
Sanjana KhalasiPosted Sep 18, 2017, 4:45 AM
Sanjana KhalasiPosted Sep 18, 2017, 4:14 AM
Ankit SharmaPosted Sep 18, 2017, 4:11 AM
Sanjana KhalasiPosted Sep 18, 2017, 4:06 AM
Ankit SharmaPosted Sep 18, 2017, 3:55 AM
Sanjana KhalasiPosted Sep 18, 2017, 3:29 AM
Ankit SharmaPosted Sep 14, 2017, 7:13 AM
Sanjana KhalasiPosted Sep 14, 2017, 7:03 AM
Ankit SharmaPosted Sep 14, 2017, 6:45 AM
Sanjana KhalasiPosted Sep 14, 2017, 6:38 AM
Sanjana KhalasiPosted Sep 14, 2017, 6:03 AM
Ankit SharmaPosted Sep 14, 2017, 5:48 AM
Sanjana KhalasiPosted Sep 14, 2017, 5:29 AM
Ankit SharmaPosted Sep 4, 2017, 4:14 AM
As per my understanding of your question, you want to add hours in input date and find the output date, where total number of hours in one day is 4.
You can use following code
Amit GuptaPosted Sep 2, 2017, 9:33 AM