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

Converting Julian Date value to Date

Status
Not open for further replies.

Joelo

MIS
Sep 27, 2003
61
0
0
Please could anybody help me out on how to convert Julian Date value to Date (mm/dd/yy)
 
I have to admin that i never used that format, if you could post an Julian date example...

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
converting Julian date values to calendar
date values. (e.g. Julian date 2451964 = 02/24/2001.)
 
Well i've found this in Microsoft help
Code:
Works for 20'th century Julian dates they says.

date=DateSerial(1900+INT(Julian_Date/1000),1,Julian_Date mod 1000)

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Well if i was feeling lazy couldnt you somehow get a spreadsheet to do that for you, they autoconvert the number into a date if the cell is in date format.
Sorry this may be totally irrelevant in ASP but in a normal windows environment id use that

The way web design should be
 
I tried the following:

caldate = DateSerial(1900+INT(jdate/1000),1,jdate mod 1000)

and got and error message:

Microsoft VBScript runtime error '800a000d'

Type mismatch

please could anyone help me out


 
date is a reserved word (sort of) and might be causing a conflict by using date= try vardate or something in the variable assignment
 
I 've tried the following:

CalD= DateSerial(1900+INT(JuianD/1000),1,JulianD mod 1000)

Got the same Error Message:

Microsoft VBScript runtime error '800a000d'

Type mismatch

 
Clipped these from
Code:
The functions below will convert a Julian date to a standard Excel date, and convert a standard Excel date to a Julian date.  

The JDateToDate function will accept a five-character Julian date and return the standard Excel date. 

Function JDateToDate(JDate As String) As Long
Dim TheYear As Integer
Dim TheDay As Integer
Dim TheDate As Long

TheYear = CInt(Left(JDate, 2))
If TheYear < 30 Then
    TheYear = TheYear + 2000
Else
    TheYear = TheYear + 1900
End If

TheDay = CInt(Right(JDate, 3))
TheDate = DateSerial(TheYear, 1, TheDay)
JDateToDate = TheDate

End Function


The DateToJDate function will accept a standard Excel date and return a five-character string representing the Julian date.  

Function DateToJDate(TheDate As Long) As String
Dim TheYear As Integer
Dim TheDays As Integer
Dim JDate As String

TheYear = Year(TheDate)
TheDays = DateDiff("d", DateSerial(TheYear, 1, 0), TheDate)
JDate = Right(Format(TheYear, "0000"), 2) & Format(TheDays, "000")
DateToJDate = JDate

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top