dbTalk Databases Forums  

DateDiff

microsoft.public.sqlserver.clients microsoft.public.sqlserver.clients


Discuss DateDiff in the microsoft.public.sqlserver.clients forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rogers
 
Posts: n/a

Default DateDiff - 09-27-2006 , 05:37 PM






I am using DateDiff format like DATEDIFF(hour,Start,End) and it gave me the
result 12 hours.

Start:- 22 Sep 2006 09:30:00
End:- 22 Sep 2006 21:00:00

Is there any way it will return me 11.5 instead of 12 because it start from
9:30 and end at 21:00 so it must be 11.5 not 12 hours right....

Can any one guid me how I can solve this.

Thanks



Reply With Quote
  #2  
Old   
Sue Hoegemeier
 
Posts: n/a

Default Re: DateDiff - 09-27-2006 , 06:46 PM






No...it wouldn't really be 11.5. The first hour is 9 and the
second hour is 21. The difference between 9 and 21 is 12,
not 11.5. Your asking for the difference based on what
integer value is returned for the hour of the datetime value
you pass in.
Perhaps you want to find the difference in minutes and use
your own logic from there? What do you want to do if it's
9:01 and 21:00?

-Sue

On Wed, 27 Sep 2006 18:37:48 -0400, "Rogers"
<rogers (AT) hotmail (DOT) com> wrote:

Quote:
I am using DateDiff format like DATEDIFF(hour,Start,End) and it gave me the
result 12 hours.

Start:- 22 Sep 2006 09:30:00
End:- 22 Sep 2006 21:00:00

Is there any way it will return me 11.5 instead of 12 because it start from
9:30 and end at 21:00 so it must be 11.5 not 12 hours right....

Can any one guid me how I can solve this.

Thanks



Reply With Quote
  #3  
Old   
samay
 
Posts: n/a

Default Re: DateDiff - 09-27-2006 , 08:59 PM



hi use this way so u will get the correct answer:

datediff(mi, from_time, to_time) / 60.00

ok got it

Rogers wrote:
Quote:
I am using DateDiff format like DATEDIFF(hour,Start,End) and it gave me the
result 12 hours.

Start:- 22 Sep 2006 09:30:00
End:- 22 Sep 2006 21:00:00

Is there any way it will return me 11.5 instead of 12 because it start from
9:30 and end at 21:00 so it must be 11.5 not 12 hours right....

Can any one guid me how I can solve this.

Thanks


Reply With Quote
  #4  
Old   
Rogers
 
Posts: n/a

Default Re: DateDiff - 10-04-2006 , 09:28 AM



Thanks

"samay" <sumi_r2 (AT) rediffmail (DOT) com> wrote

Quote:
hi use this way so u will get the correct answer:

datediff(mi, from_time, to_time) / 60.00

ok got it

Rogers wrote:
I am using DateDiff format like DATEDIFF(hour,Start,End) and it gave me
the
result 12 hours.

Start:- 22 Sep 2006 09:30:00
End:- 22 Sep 2006 21:00:00

Is there any way it will return me 11.5 instead of 12 because it start
from
9:30 and end at 21:00 so it must be 11.5 not 12 hours right....

Can any one guid me how I can solve this.

Thanks




Reply With Quote
  #5  
Old   
samay
 
Posts: n/a

Default Re: DateDiff - 10-15-2006 , 06:16 AM



hae it got worked? that date diff?


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.