Solved

Julian Date Conversion

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
t-sql Joining Issue 10 38
SQL Help 27 45
T-SQL: New to using transactions 9 25
Alternative of IN Clause in SQL Server 3 20
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
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 video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

770 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