2
Answers

sql query between date in vb

Rajavel G

Rajavel G

7y
205
1
Try
d1 = dtpfrom.Value.Date()
d2 = dtpto.Value.Date()
SQL = "SELECT Student_ID FROM Ate_entry"
execComDB(SQL)
reader = cmd.ExecuteReader()
If reader.Read() Then
reader.Close()
Try
SQL = "SELECT Student_regno,Student_Std,Student_branch,Attendance_Date,Attendance_Status,Entry_User,Entry_Date,Entry_Time FROM Ate_entry where Student_ID='" & txtstuid.Text & "' and (Attendance_Date Between '" & d1 & "' AND '" & d2 & "')"
'cmd.Parameters.AddWithValue("@from", dtpfrom.Text) ("SELECT * from stockitems where stdate Between #" & _ dtDate1.ToString("MM/dd/yyyy") & "# And #" & _dtDate2.ToString("MM/dd/yyyy") & "#",con)
'cmd.Parameters.AddWithValue("@to", dtpto.Text)
execComDB(SQL)..
 
 
 
..
I am using this code  but it not including the year....only taking month and date....

Answers (2)