i have a table with two columns first column is a (currentdate)timestamp and the other one is a (dateReturn)datetime column.i i need to get the difference between currentdate and dateReturn from number of days.is this possible?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, this is not possible.
Contrary to popular belief (and the name itself), a
timestampcolumn is not actually related to time.Disclaimer: This answer is specific to Sql Server (as per the tags of the question), other database engines might have different implementations here.*
Instead it is a 64-bit number that steadily increases. The value of the number is shared between all tables in a single database that has such a timestamp column. In other words, if you have two such tables, modify a row in one, and modify a row in the other, the value of the timestamp in the first table would be X, and in the second table would be X+1.
as per the documentation of timestamp:
As such, the value is not related to the actual date and/or time the row was inserted or last modified, and can not be converted to such a date/time in any way.
The only purpose of a
timestampcolumn is to have something unique, that is guaranteed to be increasing. Since the value is 64 bit, you will have access to18 446 744 073 709 551 616operations which require atimestampcolumn before the value resets. If you have a database that can handle a million such operations every second, you will still have to wait around 584 554 years before the value resets, so I would say it meets the uniqueness requirements.