benphp Posted February 3, 2011 Share Posted February 3, 2011 I'm hitting a SQL Server db and every table has a ts (timestamp) field that is a binary datatype - 8 bytes. Is there a way to "read" the binary and output it as a string? Quote Link to comment https://forums.phpfreaks.com/topic/226618-convert-sql-server-timestamp-ts-binary-to-string/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 3, 2011 Share Posted February 3, 2011 Which SQL server type? Also, posting an example showing what you are doing, what result you are getting, and what result you expect would help. In mysql the only 8 byte date/time is a DATETIME data type and referencing it in a string context returns a 'YYYY-MM-DD HH:MM:SS' string. Referencing it in a numerical context returns a YYYYMMDDHHMMSS value. Quote Link to comment https://forums.phpfreaks.com/topic/226618-convert-sql-server-timestamp-ts-binary-to-string/#findComment-1169625 Share on other sites More sharing options...
benphp Posted February 3, 2011 Author Share Posted February 3, 2011 Timestamp datatype is stored in 8 bytes as binary( datatype. The timestamp value is automatically updated every time a row containing a timestamp column is inserted or updated. Timestamp value is a monotonically increasing counter whose values will always be unique within a database and can be selected by queried global variable @@DBTS. --- Example: Select Grade, ts From class_Students WHERE CID = '1677' results: Grade = P ts = V Quote Link to comment https://forums.phpfreaks.com/topic/226618-convert-sql-server-timestamp-ts-binary-to-string/#findComment-1169629 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.