Q. How do I convert a Julian date to a calendar date?

Webster defines the Julian calendar as:
"the calendar as regulated by Julius Caesar, giving every fourth year 366 days,
the other years having 365 days each: the months were the same as in the 
Gregorian or New Style calendar now used."

The Julian date, not to be confused with the Julian day,
a continuous count of days from 12 noon on January 1, 4713 BC,
numbers days in each year from 001 through 365 or 366, where Jan. 1 is 001,
Feb. 28 is 059, March 1, is either 060 or 061, etc...

I have scripted FromJD.bat to convert a Julian date to a date. The syntax for using FromJD.bat is:
Call FromJD yyyy JD mm dd
yyyy is the four digit year of the Julian date you wish to convert.
JD   is a Julian date of yyyy that you wish to convert.
mm   is the call directed environment variable that will contain the 2 digit month of yyyy.
dd   is the call directed environment variable that will contain the 2 digit day of mm in yyyy.

FromJD.bat contains:
@echo off
if \{%4\}==\{\} @echo Syntax: Call FromJD yyyy JD mm ddgoto :EOF
set /a year=%1
set /a JD=1000%2%%1000
set /a leapyear=%year%%%4
set JDTMJF=000101010101010101010101010101010101010101010101010101010101010102020202020202020202020202020202020202020202020202020202
set JDTDJF=000102030405060708091011121314151617181920212223242526272829303101020304050607080910111213141516171819202122232425262728
set JDTMMD=030303030303030303030303030303030303030303030303030303030303030404040404040404040404040404040404040404040404040404040404040505050505050505050505050505050505050505050505050505050505050506060606060606060606060606060606060606060606060606060606060607070707070707070707070707070707070707070707070707070707070707080808080808080808080808080808080808080808080808080808080808080909090909090909090909090909090909090909090909090909090909091010101010101010101010101010101010101010101010101010101010101011111111111111111111111111111111111111111111111111111111111112121212121212121212121212121212121212121212121212121212121212
set JDTDMD=010203040506070809101112131415161718192021222324252627282930310102030405060708091011121314151617181920212223242526272829300102030405060708091011121314151617181920212223242526272829303101020304050607080910111213141516171819202122232425262728293001020304050607080910111213141516171819202122232425262728293031010203040506070809101112131415161718192021222324252627282930310102030405060708091011121314151617181920212223242526272829300102030405060708091011121314151617181920212223242526272829303101020304050607080910111213141516171819202122232425262728293001020304050607080910111213141516171819202122232425262728293031
if %leapyear% EQU 0 set JDTM=%JDTMJF%02%JDTMMD%&set JDTD=%JDTDJF%29%JDTDMD%
set /a JDO=%JD% * 2
call set mm=%%JDTM:~%JDO%,2%%
call set dd=%%JDTD:~%JDO%,2%%
endlocal&set %3=%mm%&set %4=%dd%
NOTE: You may wish to see the following:

How do I convert a calendar date to a Julian date?

How do I convert a date to the day number and day name?

What is the ISO week number and day for a given date?

How do I convert an ISO year, week, and day to a calendar date?

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.