Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Cast and Convert

Author  Topic 

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2007-10-09 : 10:35:31
Guys,

I have data in the format '0x000000000002F4CE' for moddatetime, how do I convert to datetime?

I have tried

SELECT CAST ('0x000000000002F4CE' AS DATETIME)

SELECT CONVERT (DATETIME, '0x000000000002F4CE')

it doesnt seem to work

Any suggestions/inputs would help

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-09 : 10:39:41
It seems to be a TIMESTAMP column, not a DATETIME.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2007-10-09 : 10:49:01
quote:
Originally posted by Peso

It seems to be a TIMESTAMP column, not a DATETIME.



E 12°55'05.25"
N 56°04'39.16"




How do I convert to datetime, is there any way to do so
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-09 : 11:07:12
You can't!
The timestamp datatype is used for "version handling" for that particular record.

The decimal value of 0x000000000002F4CE is 193742, OneHundredNinetyThreeThousandSevenHundredFourtyTwo.
If you know which datetime value it is supposed to represent, it MIGHT be doable to convert, but I doubt it.
Because you also need a second value to convert for confirmation.

As said above, the TIMESTAMP value is used as "version handling" for easier control with replication.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-09 : 11:10:35
Its a pity they ever called it TIMESTAMP. That's been deprecated and its now ROWVERSION, which explains its usage a bit better.

Note that a column with TIMESTAMP datatype will change every time the record is updated. (its basically an incrementing integer)

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-10 : 02:17:47
quote:
Originally posted by Kristen

Its a pity they ever called it TIMESTAMP. That's been deprecated and its now ROWVERSION, which explains its usage a bit better.

Note that a column with TIMESTAMP datatype will change every time the record is updated. (its basically an incrementing integer)

Kristen


Yes it is. People often mistake TIMESTAMP as Date/Time like how current_timestamp gives Datetime

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-10 : 04:17:58
I wish they would make their minds up whether its a FUNCTION() or a CONSTANT_VALUE or an @@SYSTEM_VARIABLE

The naming seems shot to hell to me.

SmallDateTime / DateTime2 / DBA-on-a-bike ...
Go to Top of Page
   

- Advertisement -