WeekNum function for BAQ's

Very nice and it got me to thinking... I believe this will calculate the correct week based on how it appears on the calendar?

if weekday(invchead.invoicedate) >= weekday(date( 1, 1, year(InvcHead.InvoiceDate))) then truncate((((InvcHead.InvoiceDate - date( 1, 1, year(InvcHead.InvoiceDate))) + 1)
/ 7) , 0) + 1 else truncate((((InvcHead.InvoiceDate - date( 1, 1, year(InvcHead.InvoiceDate))) + 1)
/ 7) , 0) + 2

--- In vantage@yahoogroups.com, Ken Williams <kwilliams@...> wrote:
>
> I developed the following query to function similar to Excel's Weeknum function. It's not exactly the same, as Excel calculates based off how it appears on a calendar, and mine is more simple in that it calculates based off 1/1 being the starting date for all calculations. For what we're doing this was good enough.
>
> truncate((((InvcHead.InvoiceDate - date( 1, 1, year(InvcHead.InvoiceDate))) + 1) / 7) , 0) + 1
>
> I wanted to post it for posterity.
>
> Ken
>
>
> [Non-text portions of this message have been removed]
>
I developed the following query to function similar to Excel's Weeknum function. It's not exactly the same, as Excel calculates based off how it appears on a calendar, and mine is more simple in that it calculates based off 1/1 being the starting date for all calculations. For what we're doing this was good enough.

truncate((((InvcHead.InvoiceDate - date( 1, 1, year(InvcHead.InvoiceDate))) + 1) / 7) , 0) + 1

I wanted to post it for posterity.

Ken


[Non-text portions of this message have been removed]