October 23, 2007 at 9:44 am
Hello,
I have two different dates:
2007-07-29 08:30:00.000
2007-07-30 12:27:00.000
I have to find the difference between these two dates, mainly.
I am using DateDiff(2007-07-29 08:30:00.000', '2007-07-30 12:27:00.000').
All that I am getting the difference is 27.95. Rather, it should be 27 hours 57 minutes.
I believe that I am doing something wrong.
Can you please help me.
thx
Ram
October 23, 2007 at 11:23 am
you're not doing anything wrong - it's a formatting trick.
95% of 1 hour = 95% of 60 minutes = .95*60 minutes= 57 minutes.
It's simply a matter of formatting (probably best left for the client app or the report to do that).
Otherwise you could try this:
declare @Tmp datetime
select @Tmp=dateadd(ss,DateDiff(ss,'2007-07-29 08:30:00.000', '2007-07-30 12:27:00.000'),0)
select @Tmp, cast((datepart(dd,@tmp)-1)*24+datepart(hh,@tmp) as varchar(30))+' hours '+cast(datepart(mi,@tmp) as varchar(30))+' minutes'
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
October 24, 2007 at 1:30 pm
Thanks Matt.
It worked.
Best Regards,
Ram
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply