2

I have the following column on my SQL table:

RECORDTIMESTAMP
0x000000000005B2A4
0x000000000005B2A5
0x000000000005B2A6

And I need to return this values on my C# program. This atributte is declared like this:

public DateTime? RecordTimeStamp{ get; set; }

And my method to get is this one:

RecordTimeStamp = DateTime.Parse(row["RecordTimeStamp"].ToString()),

The error message is the following:

  "The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.",

I also tried to declare the atribbute as string but it didn't worked also.

Any Ideas on this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
pedro lopez
  • 25
  • 2
  • 6
  • 1
    Possible duplicate of [What does a timestamp in T-Sql mean in C#?](https://stackoverflow.com/questions/6334777/what-does-a-timestamp-in-t-sql-mean-in-c) – M.Hassan Mar 28 '18 at 13:44

2 Answers2

9

A common misconeption here: Timestamp is not actual a time.

It was a miss-naming. That is why it was renamed to ROWVERSION half a dozen versions ago. Timestamp was only still used as Alias, with a clear "deprecated" marker. From https://learn.microsoft.com/en-us/sql/t-sql/data-types/rowversion-transact-sql:

timestamp is the synonym for the rowversion data type and is subject to the behavior of data type synonyms. In DDL statements, use rowversion instead of timestamp wherever possible. For more information, see Data Type Synonyms (Transact-SQL).

The Transact-SQL timestamp data type is different from the timestamp data type defined in the ISO standard.

Note

The timestamp syntax is deprecated. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

Community
  • 1
  • 1
Christopher
  • 9,634
  • 2
  • 17
  • 31
  • re the SQL Server specific bits: OP actually tagged the question as [tag:mysql]; mis-taggings happen, of course, so this context is probably good – Marc Gravell Mar 28 '18 at 13:37
0

That looks like a rowversion column (which has historically been called a "timestamp" column, despite it not being a stamp of the time). A rowversion is not a time - it is just an opaque monotonically incrementing integer that means nothing other than it lets you spot that a change has happened. Timestamps are often used for optimistic concurrency checking, but have no actual meaning. Depending on the size, a long, or a byte[] or a string might be fine for storage.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900