DateTime vs Date Performance

I have a test loop processing 1,000,000 records of timestamped information (The final application will need to process 100 to 1000 time more data).
I am having a performance issue using DateTime vs using the Deprecated Date. Example 1 takes 20 seconds to execute. Not great but not bad considering the number or rows. Example 2 takes 112 seconds, this will be unacceptable in the final application.

Example 1
For i as Integer = 0 to 1000000

Var d As New Date
d.TotalSeconds = v.TimeStamp + k1 // k1 is a constant

next i

Example 2
For i as Integer = 0 to 1000000

Var d As New DateTime(v.TimeStamp + k2, Nil) // k2 is another constant which makes the result the same

next i

Am I doing something wrong or is DateTime over 5x slower than Date? Will the Date function eventually disapear?

If you don’t need to use the date Instance (ie… just need the value for decision purposes)… the do not create a new instance inside the loop… just assign it a new value…

Var d As New Date
For i as Integer = 0 to 1000000
<some code>

d.TotalSeconds = v.TimeStamp + k1 // k1 is a constant
<more code>
next i

Unfortunately, DateTime is significantly slower than Date. If you don’t need any of the DateTime functionality I would stay with Date for now.

Thanks Dave and Kevin. I tried creating a date instance outside of the loop and it saved a couple of seconds but DateTime is still a lot slower than Date. I’ll stick with Date for now.
Note: I am just trying to convert an Integer into SQLDateTime format.

Hint : TOTALSECONDS