Solved

T-SQL Date to Julian Conversion

Posted on 2003-11-25
6
1,353 Views
Last Modified: 2009-01-27
Using T-SQL how can a date field (mm/dd/yyyy) be converted to a Julian Day Number?
0
Comment
Question by:jlindeman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Accepted Solution

by:
snimmaga earned 64 total points
ID: 9819360
0
 
LVL 6

Assisted Solution

by:lausz
lausz earned 62 total points
ID: 9819479
0
 
LVL 69

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 62 total points
ID: 9820067
Try this:

DECLARE @date SMALLDATETIME
DECLARE @julDate INT
SET @date = '2003-11-25'

SET @julDate = YEAR(@date) * 1000 +
      DATEDIFF(DAY, CAST(YEAR(@date) AS CHAR(4)) + '-01-01', @date) + 1

SELECT @julDate


Didn't know if you wanted if YYDDD or YYYYDDD, so used YYYY.
0
 
LVL 50

Assisted Solution

by:Lowfatspread
Lowfatspread earned 62 total points
ID: 9820590
Hi jlindeman,

Declare @jd int
set @Jd = Year(@date) * 1000 + Datepart(dy,@date)



Cheers!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question