Solved

Julian Date Conversion

Posted on 2003-11-06
5
3,841 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 500 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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
Via a live example, show how to shrink a transaction log file down to a reasonable size.

829 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