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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Julian date

Status
Not open for further replies.

ryan1

Programmer
May 15, 2002
106
US
Any body give me any help on coverting a Julian date to a formated date **/**/**. I'd like to be able to do it in a query, but I'm not picky any help in any way would be appreciated. Thanks.
 
Format(Date, "mmddyyyy")

just some thing to look into:)

--James junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Julian Date... what is your format? If I recall correctly from my Marine Corps Days, we used the format 02-217. If you are using that format try this (and you should be able to modiy it as necessary... or give me more specifics and I'll work with you...

You can call this function in a query... assume that you have a field JulianDate, you would enter the following in the QBE grid:

Field:
ConvertedDate: JulianToStandard(cstr(JulianDate))


Public Function JulianToStandard(ToConvert As String) As Date

Dim intYear As Integer
Dim intJulian As Integer
Dim dtmBaseDate As Date

intYear = Left(ToConvert, 2)
intJulian = Right(ToConvert, 3)

If intYear = 0 Then intYear = 2000

JulianToStandard = DateAdd("d", intJulian, "12/31/" & intYear - 1)

End Function
 
Well the format we are using is a 4-digit formula, it's really should be 5 for exaple 2320 should be 02320 but we use the 4 digit version.
 
are you only using current dates... that is will you ever have to be concerned with dates that are not in this decade... you limit yourself to a single decade by only using one digit for the year. It's not a big deal if you don't need two or four digit dates.

Any way, to work with a four digit julian date, just change the code to:

Public Function JulianToStandard(ToConvert As String) As Date

Dim intYear As Integer
Dim intJulian As Integer
Dim dtmBaseDate As Date
Dim strYear As String

intYear = Left(ToConvert, 1)
intJulian = Right(ToConvert, 3)

strYear = "200" & intYear
intYear = CInt(strYear)

JulianToStandard = DateAdd("d", intJulian, "12/31/" & intYear - 1)

End Function

Type this in the debug window:

?JulianToStandard("2027")

Will return: 1/27/02
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top