Convert Julian dates in Normal date

Vineet S 1,390 Reputation points
2024-09-19T18:36:21.3566667+00:00

How to convert Julian date column in normal date like colum contains 12490,12492 Julian dates

Azure SQL Database
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,702 questions
Developer technologies Transact-SQL
SQL Server Other
{count} votes

Accepted answer
  1. LiHongMSFT-4306 31,566 Reputation points
    2024-09-20T01:33:08.86+00:00

    Hi @Vineet S

    As far as I know, the Julian date is format as YYDDD, where YY means the two-digit form of the year and DDD means the DDDth day of that year.

    Just wondering what normal date you want to convert from 12490, because 490 clearly exceeds the maximum number of days in a year.

    Best regards,

    Cosmog


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2024-09-19T22:50:15.0466667+00:00

    simple expression:

    declare @j int = 24263; -- 2024-09-19 in Julian
    select  dateadd(dy, (@j % 1000) - 1, dateadd(yy, @j/1000, cast('2000-01-01' as date)))
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.