我有一个SELECT,它返回datagridview中一个名为datetimepicker的日期和时间的列,还有一个带有“input”或“output”标志的列。我想返回一个结果,其中datetimepicker的小时数加上标志“input”,另一个加上标志“ouput”。 你能帮帮我们吗?
...干杯
答案 0 :(得分:0)
但无论如何,请尝试以小时或分钟计算时间总和。
Dim FirstIn As String = CDate(dtp1.value.date).ToString("HH:mm") 'try with or without cdate.
Dim FirstOut As String = CDate(dtp2.value.date).ToString("HH:mm") 'try with or without cdate.
Dim elapsedTime As TimeSpan = DateTime.Parse(FirstOut).Subtract(DateTime.Parse(FirstIn))
Dim elapsedMinutesText As String = elapsedTime.Minutes.ToString()
Dim elapsedHrsText As String = elapsedTime.Hours.ToString * 60
Dim totalMinute As String = CInt(elapsedMinutesText) + CInt(elapsedHrsText)
'then try to isert it to txtbox or message box to see the result.
'but now you can get the minutes and total hours of it.
希望这就是你想要的。