Question Locked

Julian to gregorian dates

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Hi All. I have a file with julian dates that needs to be imported in MS SQL and then convert the dates to gregorian. To extract the year is easy because I just use a left function but how would I get the month and day values? The date I have is 2008001 and I need it to be 2008/01/01. Anyone with any ideas?

6 replies

by older mycroft

The ordinal date is the year number combined with the ordinal day of the year, i.e. the number of days from the beginning of the current year. This is often called the "Julian date," especially in the military, although it is based upon the Gregorian, not the Julian, calendar. The day of the year is numbered 001-365 (366 in leap years). (By definition, ordinal numbers start with 1, while cardinal numbers start with 0; sometimes day 0, or January 0, of a particular year is referred to, which is the same as December 31 of the previous year.)

According to ISO 8601:2004, the year must be written in full, i.e. YYYYDDD or YYYY-DDD, although previous editions of ISO 8601 permitted a truncated format with just the last two digits, i.e. YYDDD or YY-DDD, or no year, i.e. -DDD. As examples of the current standard, December 31, 1999, may be represented as 1999365 or 1999-365, and January 1, 2000, as 2000-001 or 2000001. The ISO standard permits only standard time representation, prefixed by the letter T, such as 2000-001T12:00:00.

Julian date format only contains DAYS.

The Julian date for:
2008 November 26 10:06:00.0 UT is
JD 2454796.92083

by john.a.wills

What Old Mycorft calls the Julian date is better called the Julian Day, named after the inventor's father. There also exists a Julian calendar, named after Julius Caesar, under whom it was introduced, and dates by it are used by most branches of the Orthodox Christian Church. It is at present about 13 days out of synchrony with the Gregorian clanedar, which is why the various fiestas are celebrated on different days by Catholic and Orthodox Christians.

by older mycroft

How influential you may feel any one branch of Christianity is, over the other. ;)

by tony hopkinson

and cursed the eejit who came up with such non-standard rubbish

I assume that 2008001 is coming in a as number?

and that it's day 1 of 2008.

select DateAdd(day,
Convert(Int,
Substring(
Convert(VarChar(7),CrapDate),5,3))),
Convert(DateTime,
Convert(VarChar(4),CrapDate) + '01-01')
From ImportwithCrapDates

I may have missed a parentheses out of that,but basically
It's start of year + (daynumber - 1)

This discussion is closed to new replies.