Reputation: 643
How can we accomplish this in vb.net : Get the start of day time and end of day time
For e.g.
Start DateTime: 05-Nov-2013 00:00:00
End DateTime: 05-Nov-2013 23:59:99
Regars
Upvotes: 2
Views: 6348
Reputation: 11773
My $.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))
Upvotes: 0
Reputation: 27322
You can add a TimeSpan
to a date value like this:
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)
Upvotes: 3
Reputation: 460058
Dim start As DateTime = yourDate.Date
Dim endTime As DateTime = yourDate.Date.AddDays(1).AddSeconds(-1)
Upvotes: 1