convert julian date in c#

I've got to convert a julian date to a normal date in c# and it is kicking - not in a friendly way. any sugestions?
Label lblDocDate = (Label)e.Row.FindControl("lblDocDate");
double timestamp = Convert.ToDouble(2455308);//this is 04/21/10 //Convert.ToDouble(drv["reserved_isvn2"]);
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
dateTime = dateTime.AddMilliseconds(timestamp);
string printDate = dateTime.ToShortDateString();
lblDocDate.Text = printDate.ToString(); // returns: 1/29/1970 10:01 AM

Open in new window

vicominAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
0
vicominAuthor Commented:
it errors on line:

if ((month == 1)(month == 2))

Error: Method name expected
0
rajapandian_81Commented:
Refer below function in below link:

http://forums.asp.net/p/1173999/1972455.aspx
public static DateTime ConvertFromJulian(int m_JulianDate)
        {

            long L = m_JulianDate + 68569;
            long N = (long) ((4*L)/146097) ;
            L = L - ((long)((146097 * N + 3)/4) );
            long I = (long) ((4000 *(L + 1)/1461001)) ;
            L = L - (long)((1461*I)/4) + 31; 
            long J = (long)((80*L)/2447); 
            int Day = (int)(L - (long)((2447*J)/80));
            L=(long)(J/11) ;
            int Month = (int)(J + 2 - 12*L);
            int Year = (int)(100*(N-49) + I + L) ;

            DateTime dt = new DateTime(Year,Month,Day);
            return dt;
        }

Open in new window

0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

vicominAuthor Commented:
another one in the last return:

return date;
    }

Error: Use of unassigned local variable 'date'
0
Éric MoreauSenior .Net ConsultantCommented:
you need to put a OR condition between the 2 parts of the conditions
0
vicominAuthor Commented:
emoreau - did this:
if ((month == 1) ||(month == 2))

rajapandian_81 - any idea how to just get the date and not time?
0
rajapandian_81Commented:
To get only date from datetime variable use below code:

string strDate = dt.ToString("MM/dd/yy");

Open in new window

0
vicominAuthor Commented:
       DateTime dt = new DateTime(Year, Month, Day);
        string strDate = dt.ToString("MM/dd/yy");
        //return dt;
        return strDate.ToString();

gives me: Cannot implicitly convert type 'string' to 'System.DateTime'
0
rajapandian_81Commented:
Change return type from DateTime to string like below


change the line
public static DateTime ConvertFromJulian(int m_JulianDate)

to
public static string ConvertFromJulian(int m_JulianDate)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.