All:
Is there any way to accurately calculate the week number for any given year?
For example, what is the week number that July 27, 2007 is in?
Can it be calculated for future dates as well?
If the year starts on a Saturday or Sunday is that considered week 1?
Do all years have 52 week numbers?
I know nothing about this, and am curious. I also want to write a winbatch program that calculates this (if possible)
Any help is greatly appreciated
Curious in Georgetown
Might take a look here...
http://winbatch.hpdd.de/
Didn't look for your specific need but might be there.
Jim
one possibility
#DefineFunction weeknumber(d)
oXL = CreateObject("Excel.Application")
oXL.Visible = 0 ;change to 0 after testing that it works
retval=oXL.WorksheetFunction.weeknum(d)
oXL=0
Return(retval)
#EndFunction
message("",weeknumber("4/16/2020") ;should return 16, assumes week begins on Sunday
Of course there are several vba calculations you and some issues over using weeknum() or ISOweeknum. However, I would stick with Jim's suggestion for a pure WB solution.
Detlev's solution in the Tech Database:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Time~-~Timer~and~Date~Functions+Current~Week~of~the~Year.txt (http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Time~-~Timer~and~Date~Functions+Current~Week~of~the~Year.txt)
to clarify or further muddle:
oXL.WorksheetFunction.weeknum(d,2) ; assumes Monday as first day of week
oXL.WorksheetFunction.weeknum(d,21) ; ISO 8601 Standard, assumes Monday and week 1 must contain the first Thursday.
Detlev's solution and the solution at the top of the Tech Support articular produces the ISO 8601 Standard week of the year.