Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Showing last 7 days records in asp page
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Showing last 7 days records in asp page

 Post Reply Post Reply
Author
usaboy View Drop Down
Newbie
Newbie
Avatar

Joined: 05 July 2003
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote usaboy Quote  Post ReplyReply Direct Link To This Post Topic: Showing last 7 days records in asp page
    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..

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 12 July 2003 at 4:44am
SELECT TOP 7 * FROM table ORDER BY date DESC;
Back to Top
TYSON View Drop Down
Groupie
Groupie


Joined: 18 August 2002
Location: Australia
Status: Offline
Points: 142
Post Options Post Options   Thanks (0) Thanks(0)   Quote TYSON Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Post Options Post Options   Thanks (0) Thanks(0)   Quote zMaestro Quote  Post ReplyReply Direct Link To This Post 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  

Back to Top
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Post Options Post Options   Thanks (0) Thanks(0)   Quote zMaestro Quote  Post ReplyReply Direct Link To This Post 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



Edited by zMaestro
Back to Top
usaboy View Drop Down
Newbie
Newbie
Avatar

Joined: 05 July 2003
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote usaboy Quote  Post ReplyReply Direct Link To This Post 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~!!!!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.