Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get avg signups a day

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
I am trying to avg how many sign-ups per day using MySQL db and ASP. Any suggestions would be helpful.

Thanks.
 
Sounds like you need a count() based on the dateOfRegistration. In SQL Server, your query might look like this...


Code:
SELECT CONVERT(VARCHAR(20), dateField, 1), COUNT(*) FROM myTable GROUP BY CONVERT(VARCHAR(20), dateField, 1) WITH CUBE

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
zen.gif

 
-or-
Code:
SELECT 
  DateAdded=CONVERT(VARCHAR(10), dateAdded, 101),
  Count=COUNT(*)
FROM Table_Name
  GROUP BY CONVERT(VARCHAR(10), dateAdded, 101) WITH CUBE
 
I am getting an error:
outputed sql statement:
SELECT CONVERT(VARCHAR(20), usersignedup, 1), COUNT(*) as cCount FROM users GROUP BY CONVERT(VARCHAR(20), usersignedup, 1) WITH CUBE

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 3.51 Driver][mysqld-4.0.20a-nt]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARCHAR(20), usersignedup, 1), COUNT(*) as cCount FROM users GR

/admin/home2.asp, line 135

www.sitesd.com
ASP WEB DEVELOPMENT
 
You may want to try this if you're have not solve this problem:


'---------------------------------------
'This example will generate the Average
'---------------------------------------
dim vsSQL
dim vdDay1, vdDay2

vdDay1 = dateSerial( 2005, 1, 1)
vdDay2 = dateSerial( 2005, 1, 5)
vsSQL = _
"SELECT COUNT(*)/DATEDIFF(d, '" & vdDay1 & "', '" & vdDay2 & "') AS avgSignUpPerDay " & _
"FROM usersTable " & _
"WHERE userSignUpDate BETWEEN '" & vdDay1 & "' AND '" & vdDay2 & "';"

'Note: Please note that if your IIS server and SQL server has a different region setting (which affects how dates are displayed), you will need to adjust for the format of vdDay1 and vdDay2.

~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top