DLG007


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




Re: convert timestamp to datetime

[rh4m1ll3] Rhamille Golimlim


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






Re: convert timestamp to datetime

Konstantin Kosinsky

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





Re: convert timestamp to datetime

Arnie Rowland

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...






Re: convert timestamp to datetime

[rh4m1ll3] Rhamille Golimlim

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





Re: convert timestamp to datetime

Samnieng

I'm use this statement.

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