Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding Datediff to staistics page

Posted on 2016-09-07
2
Medium Priority
?
87 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 53

Accepted Solution

by:
Ryan Chong earned 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

670 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