Sunday, March 11, 2012

convert timestamp to datetime

Dear all,

Could anyone advise how to convert timestemp to Datetime value using T-SQL?

for exmple of timestamp 0x00083D9C95BBF180 and I want to have it in readable datetime.

Many thanks

LG

you have to use convert

ex.

declare @.x timestamp

select @.x = convert(timestamp,getdate())

select @.x, convert(datetime,@.x) as readabledatetime, convert(smalldatetime,convert(datetime,@.x)) as readablesmalldatetime|||You couldn't convert timestamp to datetime. Timestamp is a row version not datetime of row change. When you add or update row timestamp increase
|||

AS Konstantin indicates, the timestamp datatype has nothing to do with date and time values. It is a sequential binary number that increments upon any change to the database.

It is useful for managing sequence, or determining if data has been altered. But you can't get datetime from it...

|||arnie and konstantin are correct, we'll just have to ask LG how he implemented the timestamp field or variable that he had to come up with a requirement of converting timestamp to a datetime|||

I'm use this statement.

CONVERT(CHAR(19), GETDATE(),20)

No comments:

Post a Comment