﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 Compact Edition  / select 21/(datediff(dd,getdate(),getdate()) / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 18:07:26 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: select 21/(datediff(dd,getdate(),getdate())</title><link>http://www.sqlservercentral.com/Forums/Topic608918-323-1.aspx</link><description>datediff(dd,getdate(),getdate()) IS ALWAYS 0 and therefore LESS THEN 1What is the purpose of doing that?</description><pubDate>Wed, 26 Nov 2008 04:07:34 GMT</pubDate><dc:creator>A_A_R_T</dc:creator></item><item><title>RE: select 21/(datediff(dd,getdate(),getdate())</title><link>http://www.sqlservercentral.com/Forums/Topic608918-323-1.aspx</link><description>Is that the solution you using or the problem you having?We still don't understand why you feel the need to test GETDATE vs GETDATE cause the answer is ALWAYS the same!!!! :hehe:</description><pubDate>Wed, 26 Nov 2008 04:04:23 GMT</pubDate><dc:creator>Christopher Stobbs</dc:creator></item><item><title>RE: select 21/(datediff(dd,getdate(),getdate())</title><link>http://www.sqlservercentral.com/Forums/Topic608918-323-1.aspx</link><description>HI Just see below...............select 21/ case when datediff(dd,getdate(),getdate()) &amp;lt;1 then 1 else datediff(dd,getdate(),getdate()) end</description><pubDate>Wed, 26 Nov 2008 03:57:24 GMT</pubDate><dc:creator>jagadeesh.pitchaiah</dc:creator></item><item><title>RE: select 21/(datediff(dd,getdate(),getdate())</title><link>http://www.sqlservercentral.com/Forums/Topic608918-323-1.aspx</link><description>Or is the situation something like this[code]DECLARE @TABLE TABLE(Number INT,Date1 DATETIME,Date2 DATETIME)INSERT INTO @TABLESELECT 21,GETDATE(),GETDATE() UNION ALLSELECT 21,GETDATE(),DATEADD(dd,2,GETDATE()) SELECT  Number/CASE WHEN (datediff(dd,Date1,Date2)) = 0 THEN 1 ELSE (datediff(dd,Date1,Date2)) ENDFROM @TABLE[/code]Which case I used a case statement to check for 0 before dividingyou could right it differently but a case statement would work for you.ThanksChris</description><pubDate>Wed, 26 Nov 2008 03:56:59 GMT</pubDate><dc:creator>Christopher Stobbs</dc:creator></item><item><title>RE: select 21/(datediff(dd,getdate(),getdate())</title><link>http://www.sqlservercentral.com/Forums/Topic608918-323-1.aspx</link><description>Hmm...I still don't understand what you want?This code is what I believe you're asking for:[code]select 21 / (datediff(dd,getdate(),getdate()) + 1)[/code]But you could just as easily replace (datediff(dd,getdate(),getdate()) + 1) by just 1.[code]select 21 / 1[/code]Above code is the same.Why do you want to subtract today from today ( GETDATE() - GETDATE() )? What's the purpose of doing that?</description><pubDate>Wed, 26 Nov 2008 03:55:41 GMT</pubDate><dc:creator>A_A_R_T</dc:creator></item><item><title>RE: select 21/(datediff(dd,getdate(),getdate())</title><link>http://www.sqlservercentral.com/Forums/Topic608918-323-1.aspx</link><description>Is this a real life example.Cause if you always doing a date diff with GETDATE vs GETDATE then why don't you just do this.SELECT 21I think something is missing here.Do you have sample data with other examples</description><pubDate>Wed, 26 Nov 2008 03:53:31 GMT</pubDate><dc:creator>Christopher Stobbs</dc:creator></item><item><title>RE: select 21/(datediff(dd,getdate(),getdate())</title><link>http://www.sqlservercentral.com/Forums/Topic608918-323-1.aspx</link><description>Hi Thanks for your reply..my requirement is,select 21/datediff(dd,getdate(),getdate())if I execuite above i will get an error as Msg 8134, Level 16, State 1, Line 1Divide by zero error encountered.but I want top value( ie A/datediff(dd,getdate(),getdate()), I want ans as A)the date diff is 0, but we have to make it as 1, so that I will get top value as 21.</description><pubDate>Wed, 26 Nov 2008 03:38:59 GMT</pubDate><dc:creator>jagadeesh.pitchaiah</dc:creator></item><item><title>RE: select 21/(datediff(dd,getdate(),getdate())</title><link>http://www.sqlservercentral.com/Forums/Topic608918-323-1.aspx</link><description>What do you mean? Output of 21?In your code there's a ")" missing. Like this:select 21/(datediff(dd,getdate(),getdate())[b])[/b]But it's no good anyway.This code will give you 21 as output but I'm quite sure this is not what you mean:[code]select (datediff(dd,getdate(),getdate()) + 21)[/code]</description><pubDate>Wed, 26 Nov 2008 03:23:14 GMT</pubDate><dc:creator>A_A_R_T</dc:creator></item><item><title>select 21/(datediff(dd,getdate(),getdate())</title><link>http://www.sqlservercentral.com/Forums/Topic608918-323-1.aspx</link><description>select 21/(datediff(dd,getdate(),getdate())Hi How I can get an out put of 21............</description><pubDate>Wed, 26 Nov 2008 03:09:04 GMT</pubDate><dc:creator>jagadeesh.pitchaiah</dc:creator></item></channel></rss>