Hiroyuki Tamura
asked on
MS Access Weekly query
I'm trying to create a weekly query. from Mon to Sun.
I tried format ([time],"ww") but can't understand how it works.
I tried format ([time],"ww") but can't understand how it works.
ASKER
Thank you. How does "ww" define a week?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Gus' function returns 2017W13 for today's date.
Problem is, that Format and DatePart don't always get week 53 right. Also, both week 1 and 52/53 can belong to either a calendar year before or after New Year. Thus, you need that year part as well to sort and group correctly when data spans calendar years.
/gustav
/gustav
That's why I included Year in my query example. Since year does not divide cleanly into weeks, it is necessary to decide how to handle the first week of the year when it doesn't start on the first day of the week and that also impacts the definition of the Last week of the year. The ISO method may be what Tamura wants but in this case, the correct answer is actually what satisfies the business users.
Who knows? Questioneer is silent.
/gustav
/gustav
Yes.
ASKER
Thank you all
SELECT Year([LastChangeDT]) AS ChngYear, Format([LastChangeDT],"ww"
FROM tblChangeDT
GROUP BY Year([LastChangeDT]), Format([LastChangeDT],"ww"
This query returns: