dotran
dotran

Reputation: 11

Command get julian week in DOS

What's the command line in DOS to create Julian week.

In Unix.....I have this command work fine. date +%Y%W = 201507

In DOS I can get year....but not %W. Please help. echo %date:~10,4%

Upvotes: 1

Views: 309

Answers (2)

npocmaka
npocmaka

Reputation: 57252

without powershell:

@echo off

    for /f %%W in (
        'mshta vbscript:Execute("createobject(""scripting.filesystemobject"").GetStandardStream(1).writeline(DatePart(""ww"",Now()))"^^^&close^)'
    ) do @( 
     set "weekn=%%W"
    )

echo %weekn%
set /a weekn=weekn-1
if %weekn% LSS 10 set weekn=0%weekn%
echo %weekn%

this is a small part of vbscript executed with mshta.Have on mind that vbscript starts to count weeks from 1 but unix from 0 so you might need to substract 1.

Upvotes: 1

Bill_Stewart
Bill_Stewart

Reputation: 24575

PowerShell:

"{0:yyyy}{1:D2}" -f (get-date),((get-date -uformat %W) -as [Int])

Upvotes: 1

Related Questions