How to sum column value between two dates in SQL query and show in Label

I am stuck to sum column value between 2 dates .i searched a lot but i found nothing String query = "SELECT Sum(Recieved_Amount) FROM Product where Product where Date between '"+ dateTimePicker1.Value.ToString() + "' and '" + dateTimePicker2.Value.ToString()+ "'" cmd = New SqlCommand(query) cmd.Connection = con lblset3.Text = Sum.ToString but i cannot get anything

1 answer

  • answered 2018-11-08 05:53 Nishil

    here is a dummy query. I hope this is what you are looking for.

    select sum(column_name) as [sum_val] from table_name where date_column between date1 and date2