473,231 Members | 1,540 Online

# convert Julian date to Gregorian date

How do I convert Julian Date to Calendar Date in ASP.Net 1.1 based on
following guideline found at Internet?

To convert Julian date to Gregorian date:

double JD = 2299160.5;

double Z = Math.Floor(JD+0.5);
double W = Math.Floor((Z - 1867216.25)/36524.25);
double X = Math.Floor(W/4);
double AA = Math.Floor(Z+1+W-X);
double BB = Math.Floor(AA+1524);
double CC = Math.Floor((BB-122.1)/365.25);
double DD = Math.Floor(365.25*CC);
double EE = Math.Floor((BB-DD)/30.6001);
double FF = Math.Floor(30.6001*EE);

double Day = BB-DD-FF;
double Month;
double Year;

if((EE-13) <= 12 && (EE-13) > 0)
Month = EE-13;
else
Month = EE-1;

if(Month == 1 || Month == 2)
Year = CC-4715;
else
Year = CC-4716;
Nov 19 '05 #1
1 4499
I'm not sure what you're asking. I mean, this is pretty much the code for
it. I'd be surprised if you couldn't just copy and paste this into a C#
method and be done with it.

Simply pass "JD" as a parameter to the method and return Month Day and Year
as a DateTime, string, or whatever.

Pete

"Sam" <cy********@hotmail.com> wrote in message
news:Oz**************@TK2MSFTNGP14.phx.gbl...
How do I convert Julian Date to Calendar Date in ASP.Net 1.1 based on
following guideline found at Internet?

To convert Julian date to Gregorian date:

double JD = 2299160.5;

double Z = Math.Floor(JD+0.5);
double W = Math.Floor((Z - 1867216.25)/36524.25);
double X = Math.Floor(W/4);
double AA = Math.Floor(Z+1+W-X);
double BB = Math.Floor(AA+1524);
double CC = Math.Floor((BB-122.1)/365.25);
double DD = Math.Floor(365.25*CC);
double EE = Math.Floor((BB-DD)/30.6001);
double FF = Math.Floor(30.6001*EE);

double Day = BB-DD-FF;
double Month;
double Year;

if((EE-13) <= 12 && (EE-13) > 0)
Month = EE-13;
else
Month = EE-1;

if(Month == 1 || Month == 2)
Year = CC-4715;
else
Year = CC-4716;

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.