# Julian Date Conversion

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.
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Commented:
101087 does not look like a julian date.

Running the code from above amig_g's link causes overflow

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

Commented:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=341&lngWId=5

also causes memory over flow when passing your date 101087

Commented:
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

Experts Exchange Solution brought to you by