home bbs files messages ]

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,734 of 19,505   
   Lutz Uhlmann to All   
   Re: what's going on with datediff functi   
   05 Sep 12 08:22:22   
   
   e3c08bed   
   From: news@invalid.invalid   
      
   Am 30.08.2012 21:34, schrieb justaguy:   
   > -- 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   
      
   Two issues ...   
      
   1. Use CONVERT() to make '8/23/2012' a date value   
   2. Better use the Unseperated String Format (yyyyMMdd hh:mm:ss.ttt) to   
   compare createdate with your value   
   select * from myTBL where createddate>'20120823'   
   select * from myTBL where createddate>'20120823 15:30'   
      
   http://msdn.microsoft.com/en-us/library/ms187085%28SQL.90%29.aspx   
      
   Lutz   
      
   --- 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