Reputation: 1
I would like know how to convert date in sql to julian date int,
eg.
if my date was "01 Mar 2011" how do I convert this to Julian date (734197)?
Upvotes: 0
Views: 3992
Reputation: 139
DECLARE @normal_date VARCHAR(30)='2024/3/30';
SELECT @normal_date AS NormalDate,CONVERT(varchar,(CONVERT(INT,
SUBSTRING(@normal_date,1,2))%20)+1)+ CONVERT(varchar,
SUBSTRING(CONVERT(varchar,( datepart(year, @normal_date) * 1000 +
datepart(dy, @normal_date))), 3, 5)) AS JulianDate;
Upvotes: 0
Reputation: 138980
declare @d datetime = '20110301'
select datediff(d, 0, @d) + 693596
Upvotes: 1