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
Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
SQL Server | Other
{count} votes

Answer accepted by question author
  1. LiHongMSFT-4306 31,611 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) 81,606 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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.