convert Julian date to Gregorian date

Discussion in 'ASP .Net' started by Sam, Apr 27, 2005.

  1. Sam

    Sam Guest

    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;
    Sam, Apr 27, 2005
    #1
    1. Advertising

  2. Sam

    Pete Davis Guest

    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" <> wrote in message
    news:...
    > 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;
    >
    >
    Pete Davis, Apr 27, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. h_ghanaty

    convert gregorian date to jalay date

    h_ghanaty, Nov 7, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    528
    Bret Mulvey [MS]
    Nov 9, 2003
  2. =?Utf-8?B?UmFqYQ==?=

    Convert Julian Date to VB.NET date

    =?Utf-8?B?UmFqYQ==?=, Nov 12, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    6,006
    =?Utf-8?B?UGF1bA==?=
    Nov 12, 2004
  3. =?Utf-8?B?Q2hyaXMgRGF2b2xp?=

    Gregorian to Julian Date conversion

    =?Utf-8?B?Q2hyaXMgRGF2b2xp?=, Feb 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    6,467
    Mark Rae
    Feb 3, 2005
  4. Afanasiy

    ISO to Gregorian, strptime madness

    Afanasiy, Dec 4, 2003, in forum: Python
    Replies:
    4
    Views:
    435
    Peter Hansen
    Dec 4, 2003
  5. Replies:
    2
    Views:
    1,729
    Juan T. Llibre
    Aug 13, 2006
Loading...

Share This Page