I wish to find all records between two dates. There can be more than one record per day. Some days i have`nt registerd any records.
Today (. I`m assuming the system date is 2nd of may)(2nd of May, if I register a record, This entry will not show, but records from last mont will show. If I had registered also at record 1st of may yesterday`s records would show, but not the reciord for today(2nd may).Records from last mont would also show. If I had regisered records for 1st of may and 8 of may(. I`m assuming the system date is 8th of may), only these two would show(This is not records for 10 days, only 8 .I`m assuming the system date is 8th of maydays). After the 11th there are no problem(assuming today`s system date is 11th)
I`m suspecting my query is wrong to accomplis what i want.
My problem description may be hopelessly idiotic , but hope someone understand my problem an is able to help me.
If You have other Ideas to accomplis my goal to be able to show records from the 10 last days, not the 10 last records, I`d appreciate all help I can get.
Today (. I`m assuming the system date is 2nd of may)(2nd of May, if I register a record, This entry will not show, but records from last mont will show. If I had registered also at record 1st of may yesterday`s records would show, but not the reciord for today(2nd may).Records from last mont would also show. If I had regisered records for 1st of may and 8 of may(. I`m assuming the system date is 8th of may), only these two would show(This is not records for 10 days, only 8 .I`m assuming the system date is 8th of maydays). After the 11th there are no problem(assuming today`s system date is 11th)
I`m suspecting my query is wrong to accomplis what i want.
My problem description may be hopelessly idiotic , but hope someone understand my problem an is able to help me.
If You have other Ideas to accomplis my goal to be able to show records from the 10 last days, not the 10 last records, I`d appreciate all help I can get.
Code:
Public Sub Fill_dataset()
If dgView.Height > 100 Then
<<clear datagrid
OleDbConnection.Open()
dsInCome.Clear()
dsIncome.Reset()
OleDbConnection.Close()
Else
End If
Dim myDateAs String
myDate= Now.ToShortDateString
myDate= myDate.Replace(".", "/")
Dim d As String <<day
Dim M As String = CStr(Now.Month) <<Month
Dim y As String = CStr(Now.Year) <<Year
If CDbl(Now.Day) <= 10 Then
Dim days As Double
days = CDbl(Now.Day - 1)
d = CStr(Now.AddDays(-days).Day)
Else
d = CStr(Now.AddDays(-10).Day)
End If
Dim FirstDayOfPeriod As String
FirstDayOfPeriod = M + "/" + d + "/" + y
Me.OleDbConnection.Open()
adIncome = New OleDb.OleDbDataAdapter("SELECT TypeOfIncome, From, Dato, Comment, Amount from tblIncome
WHERE tblIncome.Dato BETWEEN #" & MyDate & "# AND #" &
FirstDayOfPeriod & "# order by Dato DESC;", Me.OleDbConnection)
Dim dtIncome As DataTable
Try
adIncome.Fill(dsIncome, "dtIncome")
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message)
End Try
dgView.Height = dsIncome.Tables("dtIncome").Rows.Count * 50
frmUtgift.ActiveForm.Height = 568 220 + dgView.Height + 80
dgView.DataSource = dsIncome.Tables("dtIncome").DefaultView << gets a customized view of table
Me.OleDbConnection.Close()
end sub