我将“TimeSpan”类型转换为“日期”类型时遇到问题 如果有人可以帮我这个代码和错误:
Public Function combine(ByVal dateonly As DateTime, ByVal timeonly As DateTime)
date_Combine = DateTime.Parse(dateonly)
Time_Combine = DateTime.Parse(timeonly)
date_Combine.AddHours(Double.Parse(timeonly.Hour))
date_Combine.AddMinutes(Double.Parse(timeonly.Minute))
date_Combine.AddSeconds(Double.Parse(timeonly.Second))
Return date_Combine
End Function
For Each row As DataGridViewRow In DataGridView1.Rows
start = combine(row.Cells(1).Value, row.Cells(2).Value)
marche = combine(row.Cells(3).Value, row.Cells(4).Value)
diff = marche.Subtract(start).Hours
total += diff
Next
MessageBox.Show(total)
TextBox7.Text = total
错误:
将“TimeSpan”类型转换为“日期”类型无效。
我想知道什么是错的
注意:在我的数据库中,DateStartTasck的类型为Date(sql),格式为此(yyyy-MM-dd),TimeStartTasck的类型为Time(sql),格式为00:00:00