i've worked with fiscal years before, and the accountants always have weird rules about 4-5-4 quarters and when does fiscal week 53 happen -- because it will
so april 1 often ends up being part of the last week of the previous fiscal year and there's no hard and fast correlation to the week-of-year number that you get from the database algorithm -- just for fun, look up how Access decides when week 1 starts... i think it has something to do with the first thursday in january or something...
anyhow, craig, you may simply need to bite the bullet and create a fiscal calendar table, which you would populate a year in advance and use in all queries that need fiscal data
i've done this for several companies and in the long run it's the easiest solution
here's a hypothetical example --
Code:
caldate bus fyr fwk
2002-03-27 1.0 2002 52
2002-03-28 1.0 2002 52
2002-03-29 1.0 2002 52
2002-03-30 0.0 2002 52
2002-03-31 0.0 2003 1
2002-04-01 1.0 2003 1
2002-04-02 1.0 2003 1
2002-04-03 1.0 2003 1
caldate is primary key and is used for joining
bus says whether it's a business day -- weekends aren't, holidays aren't, and the fractional part allows you to record when the company is open only for half a business day (e.g. christmas eve)
fyr and fwk are fiscal year and week numbers
sample query: what day does the fiscal year after the one we're currently in start?
Code:
select min(caldate) from calendar
where fyr > ( select fyr from calendar
where caldate = date() )[code]
another sample query: assuming a table of daily sales by date, what are the current fiscal year's sales by week?
[code]select fyr, fwk, sum(salesamt)
from sales inner join calendar
on salesdate = caldate
where fyr = ( select fyr from calendar
where caldate = date() )
group by fyr, fwk[code]
helps?
rudy
[URL unfurl="true"]http://rudy.ca/[/URL]