Friday, October 6, 2017

How to convert from Julian date to date in SQL


DECLARE @jdejulian INT;
SET @jdejulian = 117258;
SELECT
    DATEADD(dd, CAST(RIGHT(RIGHT('0' + CAST(@jdejulian AS VARCHAR), 6),3) AS INT) - 1, DATEADD(yy, CAST(LEFT(RIGHT('0' + CAST(@jdejulian AS VARCHAR), 6),3) AS INT), 0));