How do I convert a 7-digit Julian Date (2016092
) to a regular Calendar date (MM-DD-YYYY
)?
I was thinking of taking the last three digits and converting it to a regular date then appending the first four digits as the year but I'd have to consider leap years.
Expected output: 04-01-2016
My current (SQL) code which solves the problem is
DECLARE @dt char(7)
SET @dt = 2016092
SELECT DATEADD(dd, CAST(RIGHT(@dt, 3) AS int) - 1, CAST(LEFT(@dt, 4) AS datetime))
How can I implement it on C#?