number of records per week

G

Guest

I would like to create a query that will show me the amount of records per
week for the whole year. The week begins on a Thurday and ends on a
Wednesday. I have a function() for the week call LastThurs() and is as
follows:

Function LastThurs() As Date
'This will find last Thursday's date
Dim strDates As Date
Dim intDay As Integer
intDay = Weekday(Date) 'Finds today's day of the week
Select Case intDay
Case 1 'Sunday!
strDates = Date - 3
Case 2 'Monday
strDates = Date - 4
Case 3 'Tuesday
strDates = Date - 5
Case 4 'Wednesday
strDates = Date - 6
Case 5 'Thursday
strDates = Date
Case 6 'Friday
strDates = Date - 1
Case 7 'Saturday
strDates = Date - 2
End Select
LastThurs = strDates
End Function
 
G

Guest

Just use this query --
SELECT DatePart("ww",[YourDateField],6) AS Week, Count([YourTable-1].num) AS
CountOfnum
FROM [YourTable-1]
GROUP BY DatePart("ww",[YourDateField],6);
 
G

Guest

Thanks where do you learn this stuff!!!

KARL DEWEY said:
Just use this query --
SELECT DatePart("ww",[YourDateField],6) AS Week, Count([YourTable-1].num) AS
CountOfnum
FROM [YourTable-1]
GROUP BY DatePart("ww",[YourDateField],6);


haggr said:
I would like to create a query that will show me the amount of records per
week for the whole year. The week begins on a Thurday and ends on a
Wednesday. I have a function() for the week call LastThurs() and is as
follows:

Function LastThurs() As Date
'This will find last Thursday's date
Dim strDates As Date
Dim intDay As Integer
intDay = Weekday(Date) 'Finds today's day of the week
Select Case intDay
Case 1 'Sunday!
strDates = Date - 3
Case 2 'Monday
strDates = Date - 4
Case 3 'Tuesday
strDates = Date - 5
Case 4 'Wednesday
strDates = Date - 6
Case 5 'Thursday
strDates = Date
Case 6 'Friday
strDates = Date - 1
Case 7 'Saturday
strDates = Date - 2
End Select
LastThurs = strDates
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top