Jun 30, 2012 #1 ZABARVAN IS-IT--Management Joined May 24, 2003 Messages 186 Location SA How can we fetch data from tabels meeting the current date critria. Select * from table where ord.date = ??????? ( here I need help) Will be much appreciated. Thanking you Zab
How can we fetch data from tabels meeting the current date critria. Select * from table where ord.date = ??????? ( here I need help) Will be much appreciated. Thanking you Zab
Jun 30, 2012 #2 imex Programmer Joined Feb 28, 2011 Messages 203 Location BR In the 2008 version or higher try: Code: where DateColumn = CAST(GETDATE() as DATE) In versions before 2008 try: Code: where DateColumn = CONVERT(VARCHAR(10), GETDATE(), 111) Hope this helps. [URL unfurl="true"]http://www.imoveisemexposicao.com.br/imoveis-venda-são_paulo-residencial-apartamento[/url] Upvote 0 Downvote
In the 2008 version or higher try: Code: where DateColumn = CAST(GETDATE() as DATE) In versions before 2008 try: Code: where DateColumn = CONVERT(VARCHAR(10), GETDATE(), 111) Hope this helps. [URL unfurl="true"]http://www.imoveisemexposicao.com.br/imoveis-venda-são_paulo-residencial-apartamento[/url]
Jul 1, 2012 #3 bborissov Programmer Joined May 3, 2005 Messages 5,167 Location BG Code: DECLARE @Today datetime SET @Today = DATEADD(dd,0, DATEDIFF(dd, 0, GETDATE())) SELECT ... ... WHERE ord.date >= @Today AND ord.date < @Today+1 Borislav Borissov VFP9 SP2, SQL Server Upvote 0 Downvote
Code: DECLARE @Today datetime SET @Today = DATEADD(dd,0, DATEDIFF(dd, 0, GETDATE())) SELECT ... ... WHERE ord.date >= @Today AND ord.date < @Today+1 Borislav Borissov VFP9 SP2, SQL Server
Jul 2, 2012 #4 markros Programmer Joined May 21, 2007 Messages 3,150 Location US Take a look at this blog post Bad habits to kick : mis-handling date / range queries PluralSight Learning Library Upvote 0 Downvote
Take a look at this blog post Bad habits to kick : mis-handling date / range queries PluralSight Learning Library