Hi everyone,
I have one windows application in which i have to select date range from my access database. What i want to do is I want to select a range in which the Birthday's of my friends lies (i.e birthday's falls in this range) so i need to select only date and month, here nothing to do with year. Below is my code
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & Application.StartupPath & "\EDS.accdb"
cn.Open()
Dim date1, date2, month1, month2, dat1, dat2, mon1, mon2 As String
Dim dt1, dt2 As String
date1 = DateTimePicker1.Value.Date
date2 = DateTimePicker2.Value.Date
dat1 = DatePart("d", date1)
If dat1.Length = 1 Then
dat1 = "0" & dat1
End If
dat2 = DatePart("d", date2)
If dat2.Length = 1 Then
dat2 = "0" & dat2
End If
mon1 = DatePart("M", date1)
If mon1.Length = 1 Then
mon1 = "0" & mon1
End If
mon2 = DatePart("M", date2)
If mon2.Length = 1 Then
mon2 = "0" & mon2
End If
dt1 = dat1 & "-" & mon1
dt2 = dat2 & "-" & mon2
mStrFinalQuery = "select Name, DOB from DateofBirth where format(DOB,""dd-MM"") between '" & dt1 & "' and '" & dt2 & "'"
cmd = New OleDbCommand(mStrFinalQuery, cn)
cmd.ExecuteNonQuery()
ReportsGridview.Show()
cn.Close()
here I am getting the wrong data, anyone can help me??