Double-Float to DateTime2 conversion

27 Views Asked by At

I have an original data file with timestamps providing incremental points in time, with precision in the millisecond range. So the timestamp doesn't actually have a date-time in it. Just start at 0 and each record increments by 4ms.

I took the start time (in MS serial format) as the initial seed and added the increments (converted to decimal day) so that my final result is a number for the date in serial format with 10 digits of precision (eg, 45195.3334843983). This results in a double float value.

When I first imported this into my SQL table, my timestamp column was of type datetime. But upon doing the import, all my timestamps from the data file only had the precision of seconds (mm/dd/yyyy hh:mm:ss.000). No milliseconds.

So I found the datetime2 data type and changed my table column to that type. But now when I try to do the import, it doesn't know how to convert double to datetime2.

Any suggestions on how I can overcome this problem?

I tried changing the data type in my data file from Number (with 10 decimal places) to Text (which provides the MS serial value) but this truncates the value by 5 decimal places, which loses my millisecond precision.

0

There are 0 best solutions below