Solved

Adding Datediff to staistics page

Posted on 2016-09-07
2
80 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

617 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