date - ISO week number in CMD -
how can determine (iso 8601) week number in windows batch file?
unfortunately wmic path win32_localtime /format:list
has weekinmonth...
you can use ritchie lawrences's date functions. maintained on gitub. https://ritchielawrence.github.io/batchfunctionlibrary/
here code.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :datetoweek %yy% %mm% %dd% yn cw dw :: :: by: ritchie lawrence, updated 2002-11-20. version 1.1 :: :: func: returns iso 8601 week date calendar date. :: nt4/2000/xp/2003. :: :: args: %1 year component converted, 2 or 4 digits (by val) :: %2 month component converted, leading 0 ok (by val) :: %3 day of month converted, leading 0 ok (by val) :: %4 var receive year, 4 digits (by ref) :: %5 var receive calendar week, 2 digits, 01 53 (by ref) :: %6 var receive day of week, 1 digit, 1 7 (by ref) ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: setlocal enableextensions set yy=%1&set mm=%2&set dd=%3 if 1%yy% lss 200 if 1%yy% lss 170 (set yy=20%yy%) else (set yy=19%yy%) set /a dd=100%dd%%%100,mm=100%mm%%%100 set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,jd=153*m+2 set /a jd=jd/5+dd+y*365+y/4-y/100+y/400-32045 set /a y=yy+4798,jp=y*365+y/4-y/100+y/400-31738,t=jp+3,jp=t-t%%7 set /a y=yy+4799,jt=y*365+y/4-y/100+y/400-31738,t=jt+3,jt=t-t%%7 set /a y=yy+4800,jn=y*365+y/4-y/100+y/400-31738,t=jn+3,jn=t-t%%7 set /a jr=%jp%,yn=yy-1,yn+=jd/jt,yn+=jd/jn if %jd% geq %jn% (set /a jr=%jn%) else (if %jd% geq %jt% set /a jr=%jt%) set /a diff=jd-jr,cw=diff/7+1,wd=diff%%7,wd+=1 if %cw% lss 10 set cw=0%cw% endlocal&set %4=%yn%&set %5=%cw%&set %6=%wd%&goto :eof
Comments
Post a Comment