Solved

Adding Datediff to staistics page

Posted on 2016-09-07
2
74 Views
Last Modified: 2016-09-07
I had this question after viewing Displaying number of records depdning on table contents - classic asp.

I'm trying to give my users the ability to see how many tasks had a certain status within a user defined timeframe. My code deosn't work and I've given up. Been googling by I'm a complete nuthead when it comes to programming. Any help appreciated.

<!--#include file="db/database_read.inc"-->
<head>
<!--#include file="Include/meta.asp"-->
</head>
<%
    Task = Request.querystring("Task")

  %><form method="get" action="statistics.asp" data-ajax="false">
  <fieldset class="ui-field-contain">
    <label for="Task">Number of tasks recieved</label>
    <select name="Task" id="Task">
      <option value="">Choose</option>
      <option value="7">Last week</option>
      <option value="31">Last month</option>
      <option value="91">3 months</option>
      <option value="182">6 months</option>
      <option value="273">9 months</option>
      <option value="365">12 months</option></select>
  </fieldset>
<input type="submit" data-inline="true" value="Submit" data-ajax="false">
</form><%
Dim objconn,objRSM,strSQL

Set objconn = Server.CreateObject("ADODB.Connection")
objconn.Open strConnect


strSQL = "SELECT concat(Status, ' = ' , Count(Status )) as Numrecords FROM Tasks WHERE DateDiff("d",DateR,Date())> '" & Task & "' group by Status order by Status ASC"

	     set objRSM = objconn.Execute(strSQL)
             
do while objRSM.eof = false
    Records = (objRSM("Numrecords"))
   response.write "<br>" & Records & "<br>"
   objRSM.movenext
loop
%>

Open in new window

0
Comment
Question by:micamb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Ryan Chong earned 500 total points
ID: 41787419
you may try query such as below:
SELECT concat(Status, ' = ' , Count(Status )) as Numrecords FROM Tasks
where DateDiff(current_date(), DateR) > 31
group by Status order by Status ASC

Open in new window

hence amend your codes to:
...
if Task = "" Then
   strSQL = "SELECT concat(Status, ' = ' , Count(Status )) as Numrecords FROM Tasks  group by Status order by Status ASC"
else
   strSQL = "SELECT concat(Status, ' = ' , Count(Status )) as Numrecords FROM Tasks WHERE DateDiff(current_date(), DateR) > " & Task & " group by Status order by Status ASC"
end if
	     set objRSM = objconn.Execute(strSQL)
...

Open in new window

0
 

Author Closing Comment

by:micamb
ID: 41787429
Worked like a charm - as it always does when you are involved :-)

I have a real challenge for you here:

https://www.experts-exchange.com/questions/28966125/Getting-ID-after-log-in-timed-out-Classic-asp.html?anchor=a41777693#a41777693
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Questions about INCLUDE FILES 2 46
is this a cms? 8 91
Syntax for query to update table 2 55
Display field if column exists 7 58
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question