I have a query that counts member's wedding dates in the database...
Select
Sum(NumberOfBrides) As [Wedding Count],
DATEPART( wk, WeddingDate) as [Week Number],
DATEPART( year, WeddingDate) as [Year]
FROM MemberWeddingDates
Group By DATEPART( year, WeddingDate), DATEPART( wk, WeddingDate)
Order By Sum(NumberOfBrides) Desc
How do I work out when the start and end of each week represented in the result set?
Select
Sum(NumberOfBrides) As [Wedding Count],
DATEPART( wk, WeddingDate) as [Week Number],
DATEPART( year, WeddingDate) as [Year],
??? as WeekStart,
??? as WeekEnd
FROM MemberWeddingDates
Group By DATEPART( year, WeddingDate), DATEPART( wk, WeddingDate)
Order By Sum(NumberOfBrides) Desc
This doesn't came from me but it made the job done:
I found it here.
you can also use this:
You can find the day of week and do a date add on days to get the start and end dates..
You probably also want to look at stripping off the time from the date as well though.
Here is another version. If your Scenario requires Saturday to be 1st day of Week and Friday to be last day of Week, the below code will handle that:
Below query will give data between start and end of current week starting from sunday to saturday
for Access Queries, you can use in the below format as a field
direct Calculation allowed..