Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 18,732 of 19,505    |
|    Bob Barrows to justaguy    |
|    Re: what's going on with datediff functi    |
|    04 Sep 12 11:25:17    |
      e3c08bed       From: reb01501@NOyahooSPAM.com              justaguy wrote:       > -- task: find records / rows where createddate is 8/23/2012       >       > select *       > from myTBL       > and datediff(dy,createddate,'8/23/2012') <1       >       > -- change parameter from dy to d does not help neither       > What's wrong?       >       > DBMS in question: MS SQL Server 2005 Express       >       > tia              Why not simply       WHERE CreatedDate='20120823'       ?              If times are being stored in CreatedDate, then it would be:              WHERE CreatedDate >= '20120823' and CreatedDate < '20120824'              These solutions both allow an index on CreatedDate to be used. Your datediff       solution forces a table scan.              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca