﻿<?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 / Development  / SELECT data for today's date / 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>Wed, 22 May 2013 06:01:45 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: SELECT data for today's date</title><link>http://www.sqlservercentral.com/Forums/Topic1031099-145-1.aspx</link><description>@John , it would work but its not SARGable. Or at least the date is not,  which is what we are interested in here.See the link i gave previously which describes this.</description><pubDate>Mon, 07 Mar 2011 05:36:49 GMT</pubDate><dc:creator>Dave Ballantyne</dc:creator></item><item><title>RE: SELECT data for today's date</title><link>http://www.sqlservercentral.com/Forums/Topic1031099-145-1.aspx</link><description>Hi,Would the following not work:SELECT         s.TaskID,        t.TaskName,        T.TimeStarted,        s.Action,        s.SourceHost As Source_File_Location,        s.DestFileName As Destination_FileName,        t.Success,        t.LastErrorTextFROM        Stats SJOIN Taskruns T        ON S.TASKID = T.TASKID          WHERE Success not like 'No xfers'        AND     Success like 'Failure'        AND Action not like 'Process'        AND convert(datetime,convert(varchar(12),T.TimeStarted)) =        (select convert(datetime,convert(varchar(12),getdate())))ORDER BY T.TimeStarted DESCthis essentially puts the Timestarted and getdate in the same format, which although it inserts the time, makes it 00:00.000 on both sides of the clause.Regards,John</description><pubDate>Mon, 07 Mar 2011 05:33:47 GMT</pubDate><dc:creator>john.richards</dc:creator></item><item><title>RE: SELECT data for today's date</title><link>http://www.sqlservercentral.com/Forums/Topic1031099-145-1.aspx</link><description>you could try....DECLARE @today VARCHAR(10)select @today = convert(varchar(10),getdate(),120)then use the parameter in the where clauseAND T.TimeStarted like @today+'%'or just useAND T.TimeStarted like (select convert(varchar(10),getdate(),120))+'%'</description><pubDate>Mon, 07 Mar 2011 02:48:47 GMT</pubDate><dc:creator>Fai Ho Fu</dc:creator></item><item><title>RE: SELECT data for today's date</title><link>http://www.sqlservercentral.com/Forums/Topic1031099-145-1.aspx</link><description>Please see this link[url]http://www.karaszi.com/SQLServer/info_datetime.asp[/url]</description><pubDate>Tue, 07 Dec 2010 03:43:32 GMT</pubDate><dc:creator>Dave Ballantyne</dc:creator></item><item><title>RE: SELECT data for today's date</title><link>http://www.sqlservercentral.com/Forums/Topic1031099-145-1.aspx</link><description>Hi, The latter, the display format of a datetime is as shown.The column is of Varchar(24) data type.When I insert the lines you have provided I get the error:Msg 102, Level 15, State 1, Line 17Incorrect syntax near '&amp;gt;'.[code="sql"]SELECT 	s.TaskID,	t.TaskName,	T.TimeStarted,	s.Action,	s.SourceHost As Source_File_Location,	s.DestFileName As Destination_FileName,	t.Success,	t.LastErrorTextFROM	Stats SJOIN Taskruns T	ON S.TASKID = T.TASKID		WHERE Success not like 'No xfers'	AND	Success like 'Failure'	AND Action not like 'Process'	AND (T.TimeStarted =&amp;gt; DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) -- 2010-12-07 00:00:00.000	AND T.TimeStarted &amp;lt; DATEADD(dd, 0, 1 + DATEDIFF(dd, 0, GETDATE()))) -- 2010-12-08 00:00:00.000ORDER BY T.TimeStarted DESC[/code]</description><pubDate>Tue, 07 Dec 2010 03:35:59 GMT</pubDate><dc:creator>A Little Help Please</dc:creator></item><item><title>RE: SELECT data for today's date</title><link>http://www.sqlservercentral.com/Forums/Topic1031099-145-1.aspx</link><description>What is the type of the column TimeStarted?  Is it a string or datetime?Adi</description><pubDate>Tue, 07 Dec 2010 03:29:50 GMT</pubDate><dc:creator>Adi Cohn-120898</dc:creator></item><item><title>RE: SELECT data for today's date</title><link>http://www.sqlservercentral.com/Forums/Topic1031099-145-1.aspx</link><description>[quote][b]A Little Help Please (12/7/2010)[/b][hr]I have a table which has a column called TimeStarted.The formate of the date in this column is YYYY-MM-DD HH:MM:SS[/quote]Are you saying the column holds a character-type representation of a date, in this format, or the display format of a datetime is as shown? Assuming the latter, then the following will work:[code="sql"]	AND (t.TimeStarted &amp;gt;= DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) -- 2010-12-07 00:00:00.000        AND t.TimeStarted &amp;lt; SELECT DATEADD(dd, 0, 1 + DATEDIFF(dd, 0, GETDATE()))) -- 2010-12-08 00:00:00.000[/code]Edit: changed '=&amp;gt;' to '&amp;gt;='</description><pubDate>Tue, 07 Dec 2010 03:23:03 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>SELECT data for today's date</title><link>http://www.sqlservercentral.com/Forums/Topic1031099-145-1.aspx</link><description>I have a table which has a column called TimeStarted.The formate of the date in this column is YYYY-MM-DD HH:MM:SSI want to do a SELECT against this table which ONLY pulls back data for today's date. I have tried the following and it does not bring back any data:[code="sql"]SELECT 	s.TaskID,	t.TaskName,	T.TimeStarted,	s.Action,	s.SourceHost As Source_File_Location,	s.DestFileName As Destination_FileName,	t.Success,	t.LastErrorTextFROM	Stats SJOIN Taskruns T	ON S.TASKID = T.TASKID		WHERE Success not like 'No xfers'	AND	Success like 'Failure'	AND Action not like 'Process'	AND T.TimeStarted like (select convert(varchar(10),getdate(),120))ORDER BY T.TimeStarted DESC[/code]</description><pubDate>Tue, 07 Dec 2010 03:12:41 GMT</pubDate><dc:creator>A Little Help Please</dc:creator></item></channel></rss>