?
Solved

Julian Date Conversion

Posted on 2003-11-06
5
Medium Priority
?
3,879 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
[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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Suggested Courses

777 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