2

我们如何在 vb.net 中实现这一点:获取一天的开始时间和一天的结束时间

例如

Start DateTime: 05-Nov-2013 00:00:00
End DateTime: 05-Nov-2013 23:59:99

问候

4

3 回答 3

2

您可以TimeSpan像这样将 a 添加到日期值:

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)
于 2013-11-05T12:24:36.950 回答
1
Dim start As DateTime = yourDate.Date
Dim endTime As DateTime = yourDate.Date.AddDays(1).AddSeconds(-1)
于 2013-11-05T12:20:55.163 回答
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))
于 2013-11-05T12:58:10.460 回答