December 8, 2010 at 5:53 am
hi all,
i want to minus two dates i tried but nothing below is what i have done.
DECLARE @stardt DATETIME
DECLARE @endt DATETIME
SET @stardt=CONVERT(DATETIME, '2010-12-31', 101);
SET @endt=CONVERT(DATETIME, '2010-12-25', 101)
select DATEDIFF (day, @endt,@stardt)
result=6
but it returns just the number e.g 6 days, but i want instead to return exact day e.g 2010-12-06.
thanks
December 8, 2010 at 5:58 am
Why should your result be december 6th ??
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
December 8, 2010 at 6:01 am
because i need to be like this in date not just number.
December 8, 2010 at 6:11 am
this will be a source of coming bugs !(people will actually take if for a date and not just a number of days !)
But since you insist:
-- keep in mind it will take the time part into account.
select dateadd(dd, datediff(dd, date1, date2), dateadd(mm,datediff(mm,0,date1),0))
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply