Compare time in ASP/VB

Plaidesquique

New Member
I have 2 columns, one for start-time and the other for the end-time. They both are of the type \[code\]nvarchar\[/code\] so that i can compare them.I have a text box that will receive time from the user and will post-back automatically to check if the the time is valid or not.\[code\]Dim compared_time_1 As DateTime Dim compared_time_2 As DateTime Dim select_time As SqlCommand select_time = New SqlCommand("select Start_Time , End_Time from Clinic_Schedule where Schedule_no = @sch_no", appt_DB_1) select_time.Parameters.AddWithValue("@sch_no", Sch_no) Dim time_rdr As SqlDataReader time_rdr = select_time.ExecuteReader() While time_rdr.Read compared_time_1 = DateTime.Parse(start_time_1) compared_time_2 = DateTime.Parse(end_time_1) start_time_1 = time_rdr(0).ToString end_time_1 = time_rdr(1).ToString If appt_time_txt0.Text >= start_time_1 And appt_time_txt0.Text <= end_time_1 Then date_valid_lbl0.Visible = True date_valid_lbl0.Text = "*Valid Time" Else time_valid_lbl0.Visible = True time_valid_lbl0.Text = "*Not Valid Time" End If End While time_rdr.Close()\[/code\]I don't know if i have a problem with my logic XD.the data filled in thoses columns are in this format : \[code\]00:00AM or 00:00PM.\[/code\]I will appreciate your help .. thanks
 
Back
Top