get records in todayhttp://forums.asp.net/t/1794167.aspx/1?get+records+in+todayMon, 23 Apr 2012 09:10:35 -040017941674938284http://forums.asp.net/p/1794167/4938284.aspx/1?get+records+in+todayget records in today <p>hi dear,</p> <p>I want get many count from some of table for today</p> <p>my script is :</p> <p>select <br> &nbsp;e.name,<br> (select&nbsp; COUNT(*) from&nbsp; T_ReportWork&nbsp; r where r.Engineer=e.id AND YEAR(r.DateInsert) = YEAR(GETDATE()) AND MONTH(R.dateInsert)=MONTH(GETDATE()) AND DAY(R.dateInsert)=DAY(GETDATE()) )as CompleteWork ,<br> <br> &nbsp;from T_Engineer e where e.Access='Engineer'</p> <p>but i dont have any result,complete work is zero</p> <p>are you have any siggesstion for me?</p> 2012-04-18T09:29:51-04:004938294http://forums.asp.net/p/1794167/4938294.aspx/1?Re+get+records+in+todayRe: get records in today <p></p> <blockquote><span class="icon-blockquote"></span> <h4>nazlin</h4> dont have any result</blockquote> <p></p> <p>maybe because does not have any result in the database ?</p> <p></p> 2012-04-18T09:33:27-04:004938301http://forums.asp.net/p/1794167/4938301.aspx/1?Re+get+records+in+todayRe: get records in today <p>try below code:</p> <pre class="prettyprint">select e.name,COUNT(e.*) as CompleteWork from T_ReportWork r JOIN T_Engineer e ON r.Engineer=e.id AND YEAR(r.DateInsert) = YEAR(GETDATE()) AND MONTH(R.dateInsert)=MONTH(GETDATE()) AND DAY(R.dateInsert)=DAY(GETDATE()) and e.Access='Engineer' group by e.name</pre> <p></p> 2012-04-18T09:35:19-04:004938307http://forums.asp.net/p/1794167/4938307.aspx/1?Re+get+records+in+todayRe: get records in today <p>Hi,</p> <p>It seems, the tables does not contains today data. Have you check whether it contains today data for Access='Engineer' ??</p> <p>&nbsp;</p> 2012-04-18T09:37:03-04:004938886http://forums.asp.net/p/1794167/4938886.aspx/1?Re+get+records+in+todayRe: get records in today <p>i cant understand ur problems .please exaplain full in details...</p> 2012-04-18T12:26:42-04:004938992http://forums.asp.net/p/1794167/4938992.aspx/1?Re+get+records+in+todayRe: get records in today <pre class="prettyprint">SELECT e.name, COUNT(*) AS CompleteWork FROM T_Engineer e INNER JOIN T_ReportWork r ON r.Engineer = e.id WHERE e.Access = 'Engineer' AND (r.DateInsert &gt;=DATEADD(day, DATEDIFF(day,0,GETDATE()),0) AND r.DateInsert &lt; DATEADD(day, DATEDIFF(day,0,GETDATE())&#43;1,0) ) GROUP BY e.name</pre> <p></p> 2012-04-18T13:09:23-04:004939009http://forums.asp.net/p/1794167/4939009.aspx/1?Re+get+records+in+todayRe: get records in today <pre class="prettyprint">SELECT e.name, COUNT(1) as CompleteWork FROM T_Engineer e INNER JOIN T_ReportWork r ON r.Engineer=e.id WHERE e.Access='Engineer' AND CAST(CONVERT(VARCHAR, r.DateInsert, 101) AS DATETIME) = CAST(CONVERT(VARCHAR, GETDATE(), 101) AS DATETIME) GROUP BY e.name</pre> <p>if using sql server 2008 onwards, then you can replace the condition</p> <pre class="prettyprint">AND CAST(CONVERT(VARCHAR, r.DateInsert, 101) AS DATETIME) = CAST(CONVERT(VARCHAR, GETDATE(), 101) AS DATETIME)</pre> <p>with</p> <pre class="prettyprint">AND CAST(r.DateInsert AS DATEADD) = CAST(GETDATE() AS DATEADD)</pre> 2012-04-18T13:16:10-04:004940859http://forums.asp.net/p/1794167/4940859.aspx/1?Re+get+records+in+todayRe: get records in today <p>try this</p> <pre class="prettyprint">SELECT e.name, COUNT(1) as CompleteWork FROM T_Engineer e INNER JOIN T_ReportWork r ON r.Engineer=e.id WHERE e.Access='Engineer' AND datediff(dd,r.DateInsert,GETDATE()) = 0 GROUP BY e.name</pre> 2012-04-19T11:10:58-04:004945865http://forums.asp.net/p/1794167/4945865.aspx/1?Re+get+records+in+todayRe: get records in today <p></p> <blockquote><span class="icon-blockquote"></span> <h4>nazlin</h4> <p></p> <p>hi dear,</p> <p>I want get many count from some of table for today</p> <p>my script is :</p> <p>select <br> &nbsp;e.name,<br> (select&nbsp; COUNT(*) from&nbsp; T_ReportWork&nbsp; r where r.Engineer=e.id AND YEAR(r.DateInsert) = YEAR(GETDATE()) AND MONTH(R.dateInsert)=MONTH(GETDATE()) AND DAY(R.dateInsert)=DAY(GETDATE()) )as CompleteWork ,<br> <br> &nbsp;from T_Engineer e where e.Access='Engineer'</p> <p>but i dont have any result,complete work is zero</p> <p>are you have any siggesstion for me?</p> <p></p> </blockquote> <p></p> <p>Hi,</p> <p>Did the T_Engineer table has data when e.Access = 'Engineer'? Please check your table data with below query to make sure that table has required data.</p> <pre class="prettyprint">select * from T_Engineer e where e.Access='Engineer' --check your T_Engineer table data. select COUNT(*) from T_ReportWork r where r.Engineer=e.id AND YEAR(r.DateInsert) = YEAR(GETDATE()) AND MONTH(R.dateInsert)=MONTH(GETDATE()) AND DAY(R.dateInsert)=DAY(GETDATE()) ---check your CompleteWork column</pre> <p>Thanks.</p> 2012-04-23T09:10:35-04:00