Querry for Current Week

I am using the following query to sum data for the current day. I need a separate query to sum data for the current week. Any idea how to modify this so it is Current Week?

SELECT 
    Sum(qryBookingRevenueTotals.SumofExtendedPrice) AS SumOfCountOfDAY, 
    "ADAY" AS DateSpec
FROM 
    qryBookingRevenueTotals
GROUP BY 
    DateValue(IIf(Not IsDate([qryBookingRevenueTotals].[DayRecorded]), '1/1/1950', [qryBookingRevenueTotals].[DayRecorded]))
HAVING 
    DateValue(IIf(Not IsDate([qryBookingRevenueTotals].[DayRecorded]), '1/1/1950', [qryBookingRevenueTotals].[DayRecorded])) = Date();

Open in new window

cansevinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
That would be:

HAVING
DateValue(IIf(Not IsDate([qryBookingRevenueTotals].[DayRecorded]), '1/1/1950', [qryBookingRevenueTotals].[DayRecorded])) Between DateWeekFirst(Date()) And DateWeekLast(Date())

Open in new window

Public Function DateWeekFirst( _
  ByVal datDate As Date, _
  Optional ByVal lngFirstDayOfWeek As VbDayOfWeek = vbUseSystemDayOfWeek) _
  As Date

' Returns the first date of the week of datDate.
' lngFirstDayOfWeek defines the first weekday of the week.
' 2000-09-07. Cactus Data ApS.
' 2003-05-01. System settings used as default.
' 2012-10-44. Data type of lngFirstDayOfWeek changed to VbDayOfWeek.
    
  DateWeekFirst = DateAdd("d", vbSunday - Weekday(datDate, lngFirstDayOfWeek), datDate)
    
End Function

Public Function DateWeekLast( _
  ByVal datDate As Date, _
  Optional ByVal lngFirstDayOfWeek As Long = vbUseSystemDayOfWeek) _
  As Date

' Returns the last date of the week of datDate.
' lngFirstDayOfWeek defines the first weekday of the week.
' 2000-09-07. Cactus Data ApS.
' 2003-05-01. System settings used as default.
' 2012-10-44. Data type of lngFirstDayOfWeek changed to VbDayOfWeek.
    
  DateWeekLast = DateAdd("d", vbSaturday - Weekday(datDate, lngFirstDayOfWeek), datDate)
    
End Function

Open in new window

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cansevinAuthor Commented:
Thanks Gustav.. where do I put the Public Function?
0
Gustav BrockCIOCommented:
You can open/create a module and copy/paste the functions. The goto menu and select Debug, Compile and Save.

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.