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

Jerold Schulman

August 26, 2003

1 Min Read
ITPro Today logo in a gray background | ITPro Today
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 ddWhere: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 offif {%4}=={} @echo Syntax: Call FromJD yyyy JD mm ddgoto :EOFsetlocalset /a year=%1set /a JD=1000%2%%1000set /a leapyear=%year%%%4set JDTMJF=000101010101010101010101010101010101010101010101010101010101010102020202020202020202020202020202020202020202020202020202set JDTDJF=000102030405060708091011121314151617181920212223242526272829303101020304050607080910111213141516171819202122232425262728set JDTMMD=030303030303030303030303030303030303030303030303030303030303030404040404040404040404040404040404040404040404040404040404040505050505050505050505050505050505050505050505050505050505050506060606060606060606060606060606060606060606060606060606060607070707070707070707070707070707070707070707070707070707070707080808080808080808080808080808080808080808080808080808080808080909090909090909090909090909090909090909090909090909090909091010101010101010101010101010101010101010101010101010101010101011111111111111111111111111111111111111111111111111111111111112121212121212121212121212121212121212121212121212121212121212set JDTDMD=010203040506070809101112131415161718192021222324252627282930310102030405060708091011121314151617181920212223242526272829300102030405060708091011121314151617181920212223242526272829303101020304050607080910111213141516171819202122232425262728293001020304050607080910111213141516171819202122232425262728293031010203040506070809101112131415161718192021222324252627282930310102030405060708091011121314151617181920212223242526272829300102030405060708091011121314151617181920212223242526272829303101020304050607080910111213141516171819202122232425262728293001020304050607080910111213141516171819202122232425262728293031set JDTM=%JDTMJF%%JDTMMD%set JDTD=%JDTDJF%%JDTDMD%if %leapyear% EQU 0 set JDTM=%JDTMJF%02%JDTMMD%&set JDTD=%JDTDJF%29%JDTDMD%set /a JDO=%JD% * 2call 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?


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like