I need a select from table which does not have column that tells when row was inserted, only timestamp
column (values like: 0x0000000000530278). Some data was imported to the table yesterday and now I need to find out what exactly was imported :(
Is there a way to do it using only timestamp
info? Here I found that:
Perhaps there is a way to find what was timestamp
value around specific time? That would help to form a select. Or maybe there is a well known solution?
You can use date(t_stamp) to get only the date part from a timestamp. Extracts the date part of the date or datetime expression expr.
In MySQL, use the DATE() function to retrieve the date from a datetime or timestamp value. This function takes only one argument – either an expression which returns a date/datetime/ timestamp value or the name of a timestamp/datetime column. (In our example, we use a column of the timestamp data type.)
Just as DATETIME , the TIMESTAMP data type contains both the date and the time in the following format YYYY-MM-DD hh:mm:ss . However, unlike DATETIME , the TIMESTAMP data type has a fixed range between 1970-01-01 00:00:01 UTC to 2038-01-19 03:14:07 UTC.
The Transact-SQL timestamp data type is a binary data type with no time-related values.
So to answer your question: Is there a way to get DateTime value from timestamp type column?
The answer is: No
The timestamp datatype in SQL Server 2005 is a synonym of rowversion and is just a number that is automatically incremented with each row update.
You can cast it to bigint to see its value.
To get what you want for new or updated rows, you should propably add another datetime column (lastupdate) and a trigger to update that column with each update.
For rows that have already been inserted in the past I don't think that you can do something to find the exact time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With