我们如何在vb.net中完成此任务:获取白天时间和一天结束时间
例如
Start DateTime: 05-Nov-2013 00:00:00
End DateTime: 05-Nov-2013 23:59:99
Regars
答案 0 :(得分:1)
Dim start As DateTime = yourDate.Date
Dim endTime As DateTime = yourDate.Date.AddDays(1).AddSeconds(-1)
答案 1 :(得分:1)
您可以将TimeSpan
添加到日期值,如下所示:
Dim dateValue As DateTime = DateTime.Now
Dim startTime As DateTime = dateValue.Date + New TimeSpan(0, 0, 0) 'timespan addition not actually needed here
Dim endTime As DateTime = dateValue.Date + New TimeSpan(23, 59, 59)
答案 2 :(得分:0)
我的$ .02
Dim someDate As DateTime = DateTime.Now
Dim StartDateTime As DateTime = someDate.Date
'last measurable instant for a given date
Dim EndDateTime As DateTime = someDate.Date.Add(New TimeSpan(TimeSpan.TicksPerDay - 1))