@*Echo Off *SETLOCAL :: JULIAN.BTM Convert Gregorian Date to Julian Day Number :: Author: Michael Bednarek (mb AT mbednarek.com) :: Input: dd mm yyyy :: Output: Echo DOW and JULIAN and return variable JULIAN :: Method: From a German HP Calculator Manual :: which says it only works for dates between 1-Mar-1900 and 28-Feb-2100 :: Seems to work longer, though. :: Parameters are not checked! :: bias to 1-Jan-4713 BC Set bias=1720983 :: Prepare Iff %2 gt 2 Then Set y2=%3 Set m2=%@Eval[%2 + 1] Else Set y2=%@Eval[%3 - 1] Set m2=%@Eval[%2 + 13] EndIff :: This is it Set JULIAN=%@Eval[%@Int[%@Eval[365.25 * %y2]]+%@Int[%@Eval[30.6001 * %m2]] + %1 + %bias] Set DOW=%@Word[%@Eval[%JULIAN %% 7],Sun,Mon,Tue,Wed,Thu,Fri,Sat] :: Clean up Unset y2 m2 bias :: Echo only if called from the command line If %_BATCH eq 1 Echo %JULIAN %DOW ENDLOCAL JULIAN DOW