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 2005 Forums
 Transact-SQL (2005)
 converting sql binary 4 to time

Author  Topic 

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2010-05-10 : 16:16:33
looking for a way to convert a binary4 field to a time. example i have from db is:

0x0E173000

The vendors documentation states:

Starting from the third character on the left, we represent hours, minutes, and seconds in hexadecimal by two digits each, and ignores the last two digits. For example, 0x083b2600 corresponds to 08:59:38.

Any help you folks can provide would be great.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-11 : 03:41:31

select cast(substring(col,1,1) as int),cast(substring(col,2,1) as int),cast(substring(col,3,1) as int) from your_table

Madhivanan

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

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2010-05-11 : 08:21:29
quote:
Originally posted by madhivanan


select cast(substring(col,1,1) as int),cast(substring(col,2,1) as int),cast(substring(col,3,1) as int) from your_table

Madhivanan

Failing to plan is Planning to fail



this works very well for me, i appreciate you taking the time. as always you folks are a great resource for those of us just learning the trade
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-11 : 08:54:07
quote:
Originally posted by duhaas

quote:
Originally posted by madhivanan


select cast(substring(col,1,1) as int),cast(substring(col,2,1) as int),cast(substring(col,3,1) as int) from your_table

Madhivanan

Failing to plan is Planning to fail



this works very well for me, i appreciate you taking the time. as always you folks are a great resource for those of us just learning the trade


You are welcome

Madhivanan

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

- Advertisement -