select only the month and year from datetimepicker

  • Thread starter Thread starter euchan09
  • Start date Start date
E

euchan09

Guest
hello?

can anyone please help me to select only the Month and Year and show in ListView

i use this code but it doesnt show anything:

Public Sub monthlyloadall()
monthlylv.Items.Clear()
Dim table As New DataTable
Dim ds As New DataSet
Dim selectedDate = BunifuDatepicker2.Value()
Dim startDate = New Date(selectedDate.Year, selectedDate.Month, 1)
Dim endDate = startDate.AddMonths(1)
ds.Tables.Add(table)

Dim cmd As New MySqlCommand("select item,description,price,category,date,Mode, sum(qty),sum(total)from tbl_records where `Date` >= @StartDate AND `Date` < @EndDate group by item,description,category,date,Mode order by Mode ASC", con)
cmd.Parameters.AddWithValue("@StartDate", startDate)
cmd.Parameters.AddWithValue("@EndDate", endDate)
Dim adapter As New MySqlDataAdapter(cmd)
adapter.Fill(table)
Dim row As DataRow

For Each row In table.Rows

monthlylv.Items.Add(row.Item(0))
monthlylv.Items(monthlylv.Items.Count - 1).SubItems.Add(row.Item(1))
monthlylv.Items(monthlylv.Items.Count - 1).SubItems.Add(row.Item(2))
monthlylv.Items(monthlylv.Items.Count - 1).SubItems.Add(row.Item(6))
monthlylv.Items(monthlylv.Items.Count - 1).SubItems.Add(row.Item(7))
monthlylv.Items(monthlylv.Items.Count - 1).SubItems.Add(row.Item(5))
monthlylv.Items(monthlylv.Items.Count - 1).SubItems.Add(row.Item(4))
Next

End Sub

my datetimepicker code is :

Private Sub BunifuDatepicker2_onValueChanged(sender As Object, e As EventArgs) Handles BunifuDatepicker2.onValueChanged
If BunifuDatepicker2.Value.Day <> 1 Then
BunifuDatepicker2.Value = DateSerial(BunifuDatepicker2.Value.Year, BunifuDatepicker2.Value.Month, 1)
End If

End Sub
can anyone please help me? THANK YOU!

Continue reading...
 
Back
Top