Number of Week

  • Thread starter Thread starter Thomas Karer
  • Start date Start date
T

Thomas Karer

Hi!

i want to prompt the number of the week to my users at login.

But this seams not so easy....if found a lot of script to get day of week,
and so on... but i didn´t find a way to get the Number Of Week.
has anybody a working solution?

i tried fdate.exe, this is really a marvelous piece of equipment but even
with this nice tool i can´t get the number of week...

i tried to calculate a little bit with date strings extracted with some
batch files i found here in the group and around the web but it didn´t work
as expected.

thank you very very much!

tom
 
Hi!

i want to prompt the number of the week to my users at login.

But this seams not so easy....if found a lot of script to get day of week,
and so on... but i didn´t find a way to get the Number Of Week.
has anybody a working solution?

i tried fdate.exe, this is really a marvelous piece of equipment but even
with this nice tool i can´t get the number of week...

i tried to calculate a little bit with date strings extracted with some
batch files i found here in the group and around the web but it didn´t work
as expected.

thank you very very much!

tom

I had this saved - google for Ritchie Lawrence's website to see if there is
an update.



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: D2WN %yy% %mm% %dd% WN
::
:: By: Ritchie Lawrence, 13th August 2002. Version 1.0
::
:: Func: Converts date components into Week Numbers as per ISO 8601. Weeks
:: start on a Monday. Functionally equivalent to the Excel function
:: WEEKNUM. For NT4/2K/XP.
::
:: Args: %1 year component to be converted, 2 or 4 digits (by val)
:: %2 month component to be converted, leading zero ok (by val)
:: %3 date component to be converted, leading zero ok (by val)
:: %4 Var to receive Week Number in the range 01-53 (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal ENABLEEXTENSIONS
set D2WN.yy=%1&set D2WN.mm=%2&set D2WN.dd=%3
if 1%D2WN.yy% LSS 200 if 1%D2WN.yy% LSS 180^
(set D2WN.yy=20%D2WN.yy%) else (set D2WN.yy=19%D2WN.yy%)
set /a D2WN.dd=100%D2WN.dd%%%100,D2WN.mm=100%D2WN.mm%%%100
set /a D2WN.z=14-D2WN.mm,D2WN.z/=12,D2WN.y=D2WN.yy+4800-D2WN.z
set /a D2WN.m=D2WN.mm+12*D2WN.z-3,D2WN.JDN=153*D2WN.m+2
set /a D2WN.JDN=D2WN.JDN/5+D2WN.dd+D2WN.y*365+^
D2WN.y/4-D2WN.y/100+D2WN.y/400-32045
set /a D2WN.a=D2WN.JDN%%7,D2WN.a=D2WN.JDN+31741-D2WN.a
set /a D2WN.a=D2WN.a%%146097%%36524%%1461,D2WN.l=D2WN.a/1460
set /a D2WN.b=D2WN.a-D2WN.l,D2WN.b=D2WN.a%%365
set /a D2WN.b+=D2WN.l,D2WN.WN=D2WN.b/7,D2WN.WN+=1
if %D2WN.WN% LSS 10 set D2WN.WN=0%D2WN.WN%
endlocal&set %4=%D2WN.WN%&goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
Thomas said:
but i didn´t find a way to get the Number Of Week.

Covered e.g. in
163586 May 1 2006 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

All the best, Timo
 
foxidrive said:
I had this saved - google for Ritchie Lawrence's website to see if there
is
an update.

thank you very much i found this on his page.


++++++++++++
The DateToWeek function returns an ISO 8601 Week date from a calendar date.

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:DateToWeek %yy% %mm% %dd% yn cw dw
::
:: By: Ritchie Lawrence, Updated 2002-11-20. Version 1.1
::
:: Func: Returns an ISO 8601 Week date from a calendar date.
:: For NT4/2000/XP/2003.
::
:: Args: %1 year component to be converted, 2 or 4 digits (by val)
:: %2 month component to be converted, leading zero ok (by val)
:: %3 day of month to be converted, leading zero ok (by val)
:: %4 var to receive year, 4 digits (by ref)
:: %5 var to receive calendar week, 2 digits, 01 to 53 (by ref)
:: %6 var to receive day of week, 1 digit, 1 to 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
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
++++++++++++++

It works perfect!
thank you very much!
tom
 
Back
Top