Avatar of zimmer9
zimmer9Flag for United States of America

asked on 

How would you modify a Julian Date function (C#) so that it works for leap years?

I am working with Visual Studio 2010 and C#.

How would you modify the following Julian Date function so that it works for leap years?

public static String ConvertToJulianyyyyddd(DateTime Date)
{
    DateTime startofyear = new DateTime(Date.Year, 1, 1);
    TimeSpan dif = Date - startofyear;
    return String.Format("{0}{1:D3}", Date.Year, dif.Days);
}
ASP.NETC#.NET Programming

Avatar of undefined
Last Comment
AndyAinscow
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo