mimic
mimic

Reputation: 5224

C#: How to convert string to Julian date accordingly to the giver format?

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

Upvotes: 2

Views: 4341

Answers (2)

Lunin
Lunin

Reputation: 370

Alternatively:

julianFormatString = "0" + (dateTimeVar.Year % 100).ToString() + "0" + dateTimeVar.Day.ToString();

Upvotes: 0

riwalk
riwalk

Reputation: 14233

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

A good cheatsheet can be found here.

Upvotes: 2

Related Questions