如果有人可以帮忙:(,我首先要结合日期和时间(例如:(DatetaskStart,TimetaskStart),(DatetaskEnd,TimetaskEnd))。
在我的 dategridview 中,我想在获得的组合(任务开始的(日期,时间))和(任务结束的(日期,时间))之间进行减法,最后得到所有任务的总时间(以小时为单位) .
Dim sql As String = "select id_task, DatetaskStart ,TimetaskStart , DatetaskEnd ,TimetaskEnd from task where id_task = " & Textbox1.Text & " and Datetask Between '" & DateTimePicker1.Text & "' And '" & DateTimePicker2.Text & "';"
command.CommandText = sql
Dim Time_task as Double
Dim total as Double
Dim DateValue As Date
Dim DateValue2 As Date
connection.Open()
Dim ds As New DataSet
Dim SQLAdapter As New MySqlDataAdapter(sql, connStr)
SQLAdapter.Fill(ds, "connectString")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "connectString"
DataGridView1.AutoResizeColumns()
connection.Close()
For Each row As DataGridViewRow In DataGridView1.Rows
Time_task += (Date.TryParse(row.Cells(3).Value + " " + row.Cells(4).Value, DateValue)) - (Date.TryParse(row.Cells(1).Value + " " + row.Cells(2).Value, DateValue2))
Next
total = Time_task
TextBox7.Text = total