| Madhivanan's TSQL Blog |
My friend asked me to come up with very triky interview question which is not usually asked. I myself asked this question to some of candidates while interviewing. It is possible to to apply arithmetic operators + and - on date columns like Date+2, Date-5 etc. Have you ever used Date+Date to know what it returns? Consider the following exampledeclare @date datetime
set @date='20000101'
select @date+@date as result
When I asked what it would return, candidates gave many answers. Some of them are
1 40000202
2 40000101
3 40000102
I guessed that all they thought was it was like addition on numbers. But the answer is
2 40000101
3 40000102
I guessed that all they thought was it was like addition on numbers. But the answer is
2099-12-31 00:00:00.000
Ok. Here is the question. What is the logic used behind that answer?
Note : Also replace 20000101 by 19000101 to confirm if you are correct....(Read whole news on source site)
Ok. Here is the question. What is the logic used behind that answer?
Note : Also replace 20000101 by 19000101 to confirm if you are correct....(Read whole news on source site)




