February 7, 2011 at 12:48 pm
Hi,
Does date diff in sqlserver 2005 gives one less day?
select datediff(day, '2011-01-17', '2011-02-07') gives the result as 21 days but actually it is 22.
Does it starts counting one day after start date or does not counts the last day.
Any help is highly appretiated.
Thanks in advance.Please help its urgent
February 7, 2011 at 12:51 pm
It looks like 21 to me on my calendar. Those dates are exactly 3 weeks apart (Monday to Monday). Why would it be 22?
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
February 7, 2011 at 12:52 pm
The simple answer is that you are wrong. The difference is 21 days.
February 7, 2011 at 12:54 pm
Thanks for the reply.
If you count from january 17 to feb 7 .the total no of days is 22.
Plesae let me know if i am wrong.
Thanks
February 7, 2011 at 12:55 pm
Are you counting "1/17 is 1, 1/18 is 2, ..."? If so, then that will give you 22, but it's incorrect because 1/17 is not 1 day different from 1/17. You have to start counting from 0 if you do that.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
February 7, 2011 at 12:56 pm
Thanks for the help.
I have understood .
Thanks
February 7, 2011 at 1:06 pm
You're welcome.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply