Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Timespan object: How do I get the Start and End DateTime?

Tags:

.net

Consider this:

Dim StartDate As DateTime = #06/12/2010 6:32PM#
Dim EndDate As DateTime = #06/13/2010 10:47PM#
Dim ElapsedSpan As TimeSpan = StartDate - EndDate

Does the TimeSpan object retain the original Start and End datetimes that make up the span period? It doesn't appear to and only seems to store the amount of time elapsed not the actual end points.

If I want this too, should I create my own class, I suppose or is there a better object?

like image 659
Chad Avatar asked Dec 22 '22 05:12

Chad


2 Answers

No, TimeSpan is a single measurement of an amount of time, not a specific start and end time.

like image 191
Samuel Neff Avatar answered Mar 15 '23 22:03

Samuel Neff


That is correct, timespan does not store anything dealing with the original dates as you used them above. The only reason you get a timespan with that is that the - operator is overloaded for datetime to return a timespan. I don't know of any class that would do this for you.

like image 37
BlackICE Avatar answered Mar 16 '23 00:03

BlackICE