Printer Version Table of Contents Project Home Page
.EXAMPLE.....: 17 Set your PC's date to a business Julian date
.CATEGORY....: examples
.DISCUSSION..:
This batch file was created by Aran Spence [CIS: 70162,3044]. Its function is to emulate the DOS DATE command, but allow the user to set the date using a business Julian date format (yyjjj) instead of mm-dd-yy.

Note the format is YYjjj. This is the BUSINESS Julian date: a date expressed as the number of days from the beginning of the year, when January 1 is day 1.

           date      BUSINESS Julian date
       -----------   --------------------
       Jan 5, 1992       92005
       Jan 5, 1993       93005
       Dec 31, 1993      93365  [Dec 31 is 365th day of year 1993]
As Aran originally wrote it, the user-prompt was virtually identical to that of the DATE command. I have modified his original version, so it now looks less like the DATE command but displays a bit more information, and so it can operate from the command line.

If the user enters a business Julian date as a command-line parameter, JDATE resets the date to that Julian date.

EXAMPLE: JDATE 92005 If there is no input parameter, /fget is used to prompt the user for a date.

Note that the user must enter both of the year digits (yy), but may enter an abbreviated set of day digits (jjj). That is, for Julian day 92005, the user is permitted to enter 925.

One handy use for JDATE is simply to find out what the current business Julian date is.

.CODE........:
@echo off

SET NewJD=%1
if not (%NewJD%)==() goto GotDate


:ShowDate
Fdate /Ff /Od1    /P"Current Gregorian date: "
Fdate /Ff /Oyyjjj /P"'Business Julian' date: "


:GetDate
GET S "Enter new date (yyddd): " /VNewJD /L
if (%NewJD%)==() goto endit


:GotDate
Fdate /Ff /A%NewJD% /Omm-dd-yy /Iyyjjj /VNewGD
if errorlevel 1 echo Invalid date "%NewJD%"
if errorlevel 1 goto GetDate

::   reset the date
DATE %NewGD%

echo SYSTEM DATE HAS BEEN RESET
Fdate /Ff /Od1    /P"Current Gregorian date: "
Fdate /Ff /Oyyjjj /P"'Business Julian' date: "


:endit
SET NewJD=
SET NewGD=
echo.