steffengy / tiberius

TDS 7.4 (mssql / Microsoft SQL Server) async driver for rust. Fork at: https://github.com/prisma/tiberius
Apache License 2.0
150 stars 2 forks source link

Is SQL Timestamp supported? #96

Closed nevi-me closed 5 years ago

nevi-me commented 5 years ago

I have a table that's got a timestamp column. Is there a way to read/write this? Should I use chrono for that?

steffengy commented 5 years ago

MSSQLs timestamp data type is a synoym of the rowversion type, which has no time semantics ("The rowversion data type is just an incrementing number and does not preserve a date or a time. [...] The Transact-SQL timestamp data type is different from the timestamp data type defined in the ISO standard.") https://docs.microsoft.com/de-de/sql/t-sql/data-types/rowversion-transact-sql?view=sql-server-2017

So the only thing that makes sense is reading it into an u64, which probably currently won't work. Maybe you can read it into a Vec<u8>, but not sure.

If your goal is to use it for time, please refer to microsofts advise: " To record a date or time, use a datetime2 data type.".

nevi-me commented 5 years ago

Thanks for the response, we're still developing, so I can to change to datetime2 as you suggest