Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Julian to Gregorian Date 2

Status
Not open for further replies.

Swi

Programmer
Feb 4, 2002
1,966
US
Can someone help me with trying to convert the a format of YYYDDD to MM/DD/YYYY format?

For example, January 1st, 2008 would be expressed as 2008001. February 1st would be 2008032 (32nd day of the year) and December 31st would be 2008366.

Any help is appreciated. Thanks.

Swi
 
This appears to do the calcs;

mystring = "2008366"
MsgBox "Result is " & DateAdd("d", CInt(Right(mystring, 3)), DateSerial(CInt(Left(mystring, 4) - 1), 12, 31))

If you need to hammer the result into the MM/DD/YYYY format there appear to be some examples at
 
Thank you for the quick reply.

Swi
 
>ref my CInt(Left(mystring, 4) - 1)
I guess it should really be CInt(Left(mystring, 4)) - 1
 
A simpler way:
DateSerial(CInt(Left(mystring, 4)), 01, CInt(Right(mystring, 3)))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
BTW, dates expressed as YYYDDD are not Julian dates - they're normal dates expressed in big-endian numeric date notation, similar to the ISO 8601 format (except that the field separators have been omitted).

Julian dates belong to the Julian calendar, which is still used by orthodox churches. Julian dates (and serial day numbers stored in Excel etc) often get confused with julian day numbers, but they're all quite different. Julian day numbers represent the number of elapsed days since the beginning of a cycle of 7,980 years and are typically used in astronomical calculations to overcome the fact that the solar year is not a number of whole calendar days. Julian Day 0 under the:
• Gregorian Calendar, is 24 November 4714 BC
• Julian Calendar, is 1 January 4713 BC
Today's Julian day number is 2,454,556.

Cheers

[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top