Click here to Skip to main content
15,888,287 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I need to create time slots using start time and end time as 8 to 5 with 20 minutes intervals,i WANT to get start time and endtime from the database table which has datetime datatype.and then i want to create timeslots for 20 minutes interval based on that starttime and end time thn those timeslots i want to store in another database table which is created in sql server. I am using c#.net.

Does anybody have solution to this problem?

Thank you





Reply
Posted
Updated 12-Sep-12 9:09am
v3
Comments
Sergey Alexandrovich Kryukov 12-Sep-12 14:40pm    
Go ahead and create them -- you got my approval. This is not a question.
--SA
Member 9413472 12-Sep-12 14:54pm    
thank you so much for your advice do you hsve any solution for my question?
Sergey Alexandrovich Kryukov 12-Sep-12 15:22pm    
I just don't see a problem. I just told you: this is not a question. Perhaps if I take a look at your code...
--SA
[no name] 12-Sep-12 14:40pm    
What have you tried?
Member 9413472 12-Sep-12 14:45pm    
for (int i = 0; i < lsbcrlocation.Items.Count; i++)
{
for (int j = 0; j < lsbcrprovider.Items.Count; j++)
{

if (lsbcrlocation.Items[i].Selected == true && lsbcrprovider.Items[j].Selected == true)
{
//string facility_name = ((Label)gvdisplaytimeslots.SelectedRow.FindControl("lblLocation")).Text;
//string provider_name = ((Label)gvdisplaytimeslots.SelectedRow.FindControl("lblProvider")).Text;
//HiddenField hfid = ((HiddenField)gvdisplaytimeslots.SelectedRow.FindControl("hfid"));
DataTable dttimeslot = (DataTable)cnt.GetRecord("Select day_start_time,day_end_time,facility_name,duration,provider_name from tblTimeSlots where facility_name='" + lsbcrlocation.Items[i].Text + "' and provider_name='" + lsbcrprovider.Items[j].Text + "'");

string stime = dttimeslot.Rows[0]["day_start_time"].ToString();
string etime = dttimeslot.Rows[0]["day_end_time"].ToString();
string duration = dttimeslot.Rows[0]["duration"].ToString();
//Datetime stattime= Convert.ToDateTime()
DateTime startTime = DateTime.Today.AddHours(Convert.ToInt16(stime));

// System.Diagnostics.Debug.Print(startTime.ToShortTimeString());

DateTime endTime = DateTime.Today.AddHours(Convert.ToInt16(etime)).AddMinutes(00);
//System.Diagnostics.Debug.Print(endTime.ToShortTimeString());

int inc = Convert.ToInt16(duration);
List<string> timeList = new List<string>();
lbltimeslots.Text = "";

while (startTime < endTime)
{
timeList.Add(startTime.ToShortTimeString());
startTime = startTime.AddMinutes(inc);
lbltimeslots.Text += startTime.ToShortTimeString();
hrcls.upindel("insert into tblValidAppointmentTime(facility_name,provider_name,first_appointment_time) values('" + lsbcrlocation.Items[i].Text + "','" + lsbcrprovider.Items[j].Text + "','" + lbltimeslots.Text + "')");

//.ToShortTimeString();

}
timeList.Add(endTime.ToShortTimeString());
}
}
}
}
I have tried with this in the above code i want to store calculated time slots in the tblvalidappointmenttime table which i have created in sql server

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900