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!

Weekly rotation of data 1

Status
Not open for further replies.

meldrape

Programmer
May 12, 2001
516
US
Greetings,

I have a SQL database view pulling in course topics and course dates. I would like to display in the browser the top five course topics for each week. The query would sort by date, pull the top five, then in 7 days do it again. Any thoughts of how to gracefully do this? Thanks.

Thank you.
Mel
 
dim weekOfYear, currentYear, firstDay
weekOfYear = datePart("WW", now())
currentYear = datePart("YYYY", now())
firstDay = dateSerial(currentYear, 1, 1)

dim date1, date2

date1 = DateAdd("WW", weekOfYear, firstDay)
date2 = DateAdd("WW", weekOfYear + 1, firstDay)

SELECT TOP 5 column1, column2, column3 FROM tableName WHERE dateField >= '&quot; & date1 & &quot;' AND dateField <= '&quot; & date2 & &quot;' ORDER BY dateField

Where dateField is the column in your database where the dates you are sorting and filtering by are contained...

:)
Paul Prewett
 
Thanks Link9, this looks like exactly what I need!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top