Jun 30, 2012 #1 ZABARVAN IS-IT--Management May 24, 2003 186 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 Feb 28, 2011 203 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 May 3, 2005 5,167 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 May 21, 2007 3,150 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