Grouping Data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, Please help... :-)

I have a query that counts the number of days between visit and closure of a
job. This gives me a vast number of results. What I am trying to do is group
them together so that its easier to report on.

I want to combine them in this way... If the days are between 0 & 6 then
Week1, if they are between 7 & 14 then Week2, if between 15 & 21 then Week3
and if greater than 21 then Week4orMore

How is this posible to do?

Thanks,
Jez
 
Presumably you mean between 0 & 6 is week1, between 7 & 13 is week2, between
14 & 20 is week3 and so on...

If so, try:

([Days] \ 7) + 1
 
posted better, posted quicker, and probably Douglas is handsomer too. (:-<)

Douglas J. Steele said:
Presumably you mean between 0 & 6 is week1, between 7 & 13 is week2,
between 14 & 20 is week3 and so on...

If so, try:

([Days] \ 7) + 1

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Jez said:
Hi, Please help... :-)

I have a query that counts the number of days between visit and closure
of a
job. This gives me a vast number of results. What I am trying to do is
group
them together so that its easier to report on.

I want to combine them in this way... If the days are between 0 & 6 then
Week1, if they are between 7 & 14 then Week2, if between 15 & 21 then
Week3
and if greater than 21 then Week4orMore

How is this posible to do?

Thanks,
Jez
 
Jez:

Add the following function to a standard module:

Public Function GetWeekGroup(dtmVisit As Date, dtmClosure As Date) As String

Dim intDays As Integer

intDays = DateDiff("d", dtmVisit, dtmClosure)

Select Case intDays
Case Is <= 6
GetWeekGroup = "Week 1"
Case 7 To 14
GetWeekGroup = "Week 2"
Case 15 To 21
GetWeekGroup = "Week 3"
Case Else
GetWeekGroup = "Week 4 or later"
End Select

End Function

Call the function in the query, passing the Visit date and the Closure date
into it, e.g.

WeekGroup:GetWeekGroup([VisitDate], [ClosureDate])

and group the query on the WeekGroup column.

Ken Sheridan
Stafford, England
 
Thanks Ken. Works perfect.

Ken Sheridan said:
Jez:

Add the following function to a standard module:

Public Function GetWeekGroup(dtmVisit As Date, dtmClosure As Date) As String

Dim intDays As Integer

intDays = DateDiff("d", dtmVisit, dtmClosure)

Select Case intDays
Case Is <= 6
GetWeekGroup = "Week 1"
Case 7 To 14
GetWeekGroup = "Week 2"
Case 15 To 21
GetWeekGroup = "Week 3"
Case Else
GetWeekGroup = "Week 4 or later"
End Select

End Function

Call the function in the query, passing the Visit date and the Closure date
into it, e.g.

WeekGroup:GetWeekGroup([VisitDate], [ClosureDate])

and group the query on the WeekGroup column.

Ken Sheridan
Stafford, England

Jez said:
Hi, Please help... :-)

I have a query that counts the number of days between visit and closure of a
job. This gives me a vast number of results. What I am trying to do is group
them together so that its easier to report on.

I want to combine them in this way... If the days are between 0 & 6 then
Week1, if they are between 7 & 14 then Week2, if between 15 & 21 then Week3
and if greater than 21 then Week4orMore

How is this posible to do?

Thanks,
Jez
 

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

Back
Top