select between two dates

show all records between two dates including the start date and end da

Page 1 of 1

4 Replies - 9149 Views - Last Post: 10 November 2017 - 10:39 AM Rate Topic: -----

#1 yangma  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 51
  • Joined: 03-May 09

select between two dates

Posted 21 June 2009 - 10:57 PM

 cmd = New SqlCommand("select * from employee_log where log_datetime >='" + DateTimePicker1.Value.Date + "'   And  log_datetime<= '" + DateTimePicker2.Value.Date + "'	", cn)

suppose if i select two dates june 21 and june 30 then records between 21 and 30 including 21 and 30 should be shown..but the records of june 30 is not shown..only from 21 to 29 is shown by this code...
wat should i add or edit to this code??thanks

Is This A Good Question/Topic? 0
  • +

Replies To: select between two dates

#2 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: select between two dates

Posted 21 June 2009 - 11:38 PM

simply use
cmd = New SqlCommand("select * from employee_log where log_datetime Between '" + DateTimePicker1.Value.Date + "'   And  '" + DateTimePicker2.Value.Date + "'    ", cn)


Let Know it Was Help Full :)
Was This Post Helpful? 0
  • +
  • -

#3 yangma  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 51
  • Joined: 03-May 09

Re: select between two dates

Posted 22 June 2009 - 12:09 AM

that results same as above .....last date is not showing
Was This Post Helpful? 0
  • +
  • -

#4 Hdefcon-mwas  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-April 16

Re: select between two dates

Posted 10 November 2017 - 10:37 AM

 Dim con As New MySqlConnection
        con.ConnectionString = ("server=localhost;user id=root;password=;database=stocktaking_record_management_system_database")
        con.Open()

        Dim searchQuery As String = "select * from order_table where o_date Between '" + DateTimePicker1.Text + "'   And  '" + DateTimePicker2.Text + "'"

        Dim command As New MySqlCommand(searchQuery, con)
        Dim adapter As New MySqlDataAdapter(command)
        Dim table As New DataTable()

        adapter.Fill(table)
        '///name of datagrid view is dgv_generate_report
        dgv_generate_report.DataSource = table


Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13485
  • View blog
  • Posts: 53,847
  • Joined: 12-June 08

Re: select between two dates

Posted 10 November 2017 - 10:39 AM

AHhhh, what?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1