comparing two timestamp

  • Thread starter Thread starter Next
  • Start date Start date
N

Next

I would like to compare to byte arrays.
Each array contains a timestamp from SQL database.

byte[] _ts1 = {0x00000000,...};
byte[] _ts2 = {0x00000001,...};

//this is what I am trying to do:
if ( _ts2 > _ts1)
_ts1 = _ts2;

How is the timestamp evaluated? In SQL I can compare them, and choose min or
max.
I can't figure out how to compare them in C#.
Thanks in advance for ANY ;) help or suggestions you would give!
Aaron
 
What are you trying to do with the timestamp data? In SQL Server,
timestamp is not the same as the SQL-92 timestamp (which is equivalent
to datetime), it is a binary(8) value that is guaranteed to be unique
within a database and is changed by the engine each time a row is
modified. So using min or max would be relatively meaningless in that
context -- all you need to do is to see if one is equal to the other
if you're trying to detect concurrency violations. For more
information on timestamp, see SQL Books Online.

--Mary
 
I am monitoring a set of rows.

I want to query for only the rows that have changed since my last query. In
other words I want all the rows that have a timestamp greater than the last
time stamp.

hence:

//this is what I am trying to do:
if ( _ts2 > _ts1)
_ts1 = _ts2;


Mary Chipman said:
What are you trying to do with the timestamp data? In SQL Server,
timestamp is not the same as the SQL-92 timestamp (which is equivalent
to datetime), it is a binary(8) value that is guaranteed to be unique
within a database and is changed by the engine each time a row is
modified. So using min or max would be relatively meaningless in that
context -- all you need to do is to see if one is equal to the other
if you're trying to detect concurrency violations. For more
information on timestamp, see SQL Books Online.

--Mary

I would like to compare to byte arrays.
Each array contains a timestamp from SQL database.

byte[] _ts1 = {0x00000000,...};
byte[] _ts2 = {0x00000001,...};

//this is what I am trying to do:
if ( _ts2 > _ts1)
_ts1 = _ts2;

How is the timestamp evaluated? In SQL I can compare them, and choose min or
max.
I can't figure out how to compare them in C#.
Thanks in advance for ANY ;) help or suggestions you would give!
Aaron
 
replied to your new post. hope that helps... i have converted from byte
arrays to base 64s though never timestamp byte[] but that should not matter.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
Next said:
I am monitoring a set of rows.

I want to query for only the rows that have changed since my last query. In
other words I want all the rows that have a timestamp greater than the last
time stamp.

hence:

//this is what I am trying to do:
if ( _ts2 > _ts1)
_ts1 = _ts2;


Mary Chipman said:
What are you trying to do with the timestamp data? In SQL Server,
timestamp is not the same as the SQL-92 timestamp (which is equivalent
to datetime), it is a binary(8) value that is guaranteed to be unique
within a database and is changed by the engine each time a row is
modified. So using min or max would be relatively meaningless in that
context -- all you need to do is to see if one is equal to the other
if you're trying to detect concurrency violations. For more
information on timestamp, see SQL Books Online.

--Mary

I would like to compare to byte arrays.
Each array contains a timestamp from SQL database.

byte[] _ts1 = {0x00000000,...};
byte[] _ts2 = {0x00000001,...};

//this is what I am trying to do:
if ( _ts2 > _ts1)
_ts1 = _ts2;

How is the timestamp evaluated? In SQL I can compare them, and choose
min
 
You don't need to test for greater than, just test for equality. If
the timestamp is different, then the row was changed.

--Mary

I am monitoring a set of rows.

I want to query for only the rows that have changed since my last query. In
other words I want all the rows that have a timestamp greater than the last
time stamp.

hence:

//this is what I am trying to do:
if ( _ts2 > _ts1)
_ts1 = _ts2;


Mary Chipman said:
What are you trying to do with the timestamp data? In SQL Server,
timestamp is not the same as the SQL-92 timestamp (which is equivalent
to datetime), it is a binary(8) value that is guaranteed to be unique
within a database and is changed by the engine each time a row is
modified. So using min or max would be relatively meaningless in that
context -- all you need to do is to see if one is equal to the other
if you're trying to detect concurrency violations. For more
information on timestamp, see SQL Books Online.

--Mary

I would like to compare to byte arrays.
Each array contains a timestamp from SQL database.

byte[] _ts1 = {0x00000000,...};
byte[] _ts2 = {0x00000001,...};

//this is what I am trying to do:
if ( _ts2 > _ts1)
_ts1 = _ts2;

How is the timestamp evaluated? In SQL I can compare them, and choose min or
max.
I can't figure out how to compare them in C#.
Thanks in advance for ANY ;) help or suggestions you would give!
Aaron
 
Hi Mary,

Thank you for your reply. Please see the new thread above

"Help! compare two SQL timestamps in C# byte arrays"






Mary Chipman said:
You don't need to test for greater than, just test for equality. If
the timestamp is different, then the row was changed.

--Mary

I am monitoring a set of rows.

I want to query for only the rows that have changed since my last query. In
other words I want all the rows that have a timestamp greater than the last
time stamp.

hence:

//this is what I am trying to do:
if ( _ts2 > _ts1)
_ts1 = _ts2;


Mary Chipman said:
What are you trying to do with the timestamp data? In SQL Server,
timestamp is not the same as the SQL-92 timestamp (which is equivalent
to datetime), it is a binary(8) value that is guaranteed to be unique
within a database and is changed by the engine each time a row is
modified. So using min or max would be relatively meaningless in that
context -- all you need to do is to see if one is equal to the other
if you're trying to detect concurrency violations. For more
information on timestamp, see SQL Books Online.

--Mary

On Fri, 17 Sep 2004 13:23:25 -0700, "Next"

I would like to compare to byte arrays.
Each array contains a timestamp from SQL database.

byte[] _ts1 = {0x00000000,...};
byte[] _ts2 = {0x00000001,...};

//this is what I am trying to do:
if ( _ts2 > _ts1)
_ts1 = _ts2;

How is the timestamp evaluated? In SQL I can compare them, and choose
min
or
max.
I can't figure out how to compare them in C#.
Thanks in advance for ANY ;) help or suggestions you would give!
Aaron
 
Back
Top