Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Julian Date Conversion

Posted on 2003-11-06
5
Medium Priority
?
3,919 Views
Last Modified: 2012-05-04
I am using SQL server 2000 with data from as/400 dts transfer. I have a date field with julian dates that look like this:

101087

Any idea how to convert this date to regular date in display in frontpage created databse wizard results. I have tried to tweek SQL drive in odbc admin. no luck as of yet.
0
Comment
Question by:timokeeffe
  • 3
5 Comments
 
LVL 58

Expert Comment

by:amit_g
ID: 9697236
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9697361
101087 does not look like a julian date.

Running the code from above amig_g's link causes overflow

select dateadd(dd,  (101087-2415021), convert(datetime, '1900-01-01',103))

101087 look like a normal date in the format of (mmddyyyy)

0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9697471
Code I downloaded from the link
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=341&lngWId=5

also causes memory over flow when passing your date 101087

0
 
LVL 9

Accepted Solution

by:
PaulBarbin earned 2000 total points
ID: 9698129
Agreed, if it were a Julian date it would represent roughly 4437 BC.  If its just a date of October 10, 1987 (is it 19?) then something like this might work, depending on whether single digit days and single digit months are padded (example: January 1987 would like like this: 010187)

declare @dt varchar(6)
set @dt = '101087'

select convert(datetime, substring(@dt,1,2) + '-' + substring(@dt,3,2) + '-19' + substring(@dt,5,2))

If its not padded, then you wouldn't be able to distinguish January 11th from November 1st.

Also, my code assumes 19 as the century, you could try to look at the year and decide which century to use (under 50 = 2000, over 50 = 1900).

Paul
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9954916
Would you need further help? If not please close this issue. :)
Regards.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

824 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