Print Page | Close Window

Showing last 7 days records in asp page

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=4203
Printed Date: 30 March 2026 at 6:30am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Showing last 7 days records in asp page
Posted By: usaboy
Subject: Showing last 7 days records in asp page
Date Posted: 11 July 2003 at 3:35pm

I have a page.. written in ASP/VBscript... and i need a SQL Query to retrive last 7 days records... and if possible.. find out the total number of records for each day ie. 1st, 2nd, ... 7th etc.

any idea how i can write the SQL query for that.. btw.. the database is MS Access database..




Replies:
Posted By: Mart
Date Posted: 12 July 2003 at 4:44am
SELECT TOP 7 * FROM table ORDER BY date DESC;


Posted By: TYSON
Date Posted: 12 July 2003 at 7:57am

This should get you the last 7 days records

SELECT  * FROM  tblThread WHERE (DATEDIFF(d, Message_date, Now()) <= 7)

Replace tblthread with you table name and message_date with your Date Field name. Ive only tested it on SQL server but i cant see why it wont work with access.

Your second question stumps me as i cant see an efficient way of doing it.



-------------
http://www.fuo-motorsports.com/ - http://www.fuo-motorsports.com/


Posted By: zMaestro
Date Posted: 13 July 2003 at 5:30am
Originally posted by TYSON TYSON wrote:

This should get you the last 7 days records

SELECT  * FROM  tblThread WHERE (DATEDIFF(d, Message_date, Now()) <= 7)

WOW... nice shot  



Posted By: zMaestro
Date Posted: 13 July 2003 at 5:37am

for the second.. but i don't know if it will be good to use... u can add recordcount.. and then use:

SELECT  * FROM  tblThread WHERE (DATEDIFF(d, Message_date, Now()) = 1)

and i = r.RecordCount (where i and r are......)

then SELECT  * FROM  tblThread WHERE (DATEDIFF(d, Message_date, Now()) =2 )

and i = r.RecordCount

 

 

n.b. will be wonderful if this made in a loop.. ranges from 1 to 7.... WOW

and so on



Posted By: usaboy
Date Posted: 13 July 2003 at 4:50pm
tanx guys... i did use all the method.. but it seems to be ok with SQL Server but not the MS ACCESS.. i keep get the error message of too few parameters~!!!!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net