2

my question is how to convert input DateTime value into Julian date format but the result should be in the format "0YYDDD"? I suppose January, 2nd 2011 should look like "011002".

Thanks

AakashM
  • 62,551
  • 17
  • 151
  • 186
mimic
  • 4,897
  • 7
  • 54
  • 93
  • Just to note, what you are talking about - that is, the day-of-year - is the Julian *date*. The Julian *calendar* is something else: it's an 'earlier version' of the Gregorian calendar generally used now, with the difference that it didn't have the century/four-century leap year rules http://en.wikipedia.org/wiki/Julian_calendar – AakashM Dec 09 '10 at 21:38

2 Answers2

2
DateTime dt = new DateTime(2011, 1, 2);
Console.WriteLine( String.Format("{0:0yy0dd}",dt) );

A good cheatsheet can be found here.

riwalk
  • 14,033
  • 6
  • 51
  • 68
0

Alternatively:

julianFormatString = "0" + (dateTimeVar.Year % 100).ToString() + "0" + dateTimeVar.Day.ToString();
Lunin
  • 370
  • 2
  • 9