We help IT Professionals succeed at work.

CONVERT DATE TO JULIAN

SnowLapa
SnowLapa used Ask the Experts™
on
Hello,

I found this code and it appears that it should do what I need but I keep getting syntax errors and the VAL & FORMAT seem incorrect in VB Script.  

I need to take this code and make it work in a VB script.
'JD EDWARDS (AS/400 software) uses dates called JULIAN. 
'A JULIAN Date identifies the year first, then the number of days into the year that
'his date appears. So, Jan 15, 1999 is 99015. March 15 is 99074. March 15, 2001 is
'101074 Dates in Y2K start with 100 (2000), 101(2001) etc.

StartDate = Format("01/15/2000")
TempFromDate = DateValue(StartDate)
TempYr = 100 + Val(Format(TempFromDate, "yyyy")) - Val(Format(DateValue("01/01/2000"), "yyyy"))

TempYr = TempYr * 1000
TempString = "01/01/" + Format(TempFromDate, "yyyy")
fromdate = TempYr + TempFromDate - DateValue(TempString) + 1

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2005

Commented:
http://www.rodsdot.com/asp/Julian_Date.asp
<%
Dim dt, yr, first, julian

dt = Date ' Today
yr = Year(dt) ' This year
first = DateSerial(yr, 1, 1) ' First day of this year
' right year 2 and number of days since first of the year padded left 
' with zeros as needed to be 3 digits.
julian = Right(yr,2) & Right("000" & (DateDiff("d",first,dt)+1),3)
Response.Write julian
%>

Open in new window

Author

Commented:
I can't seem to get to that site.....

Thanks
Top Expert 2005

Commented:
Site's timing out and running slow. Very unusual for this ISP. You can run the script posted on your own development server if you can not get my example page to load.
Top Expert 2005

Commented:
I had to add 1 more to the days from the beginning of the year part, be sure to pick up the correction.

Author

Commented:
I tried what you had attached and my results are 10182.  I have a GUI converter and for today my julian is 110183 -----> CYYDDD

Author

Commented:
Try this app and you will see what I mean......
Julian-Dates.exe
Top Expert 2005

Commented:
I don't download exe or com applications.

I told you "I had to add 1 more to the days from the beginning of the year part"

and "be sure to pick up the correction."

It is correct, both above and on the example page.  110183 is next year, an not a valid Julian date: it should be 10183, i.e. YYDDD not YY0DDD.

Rod
Top Expert 2005

Commented:
Top Expert 2005
Commented:
http://www.rodsdot.com/asp/Julian_Date.asp modified to add 100 to years greater than 2000.

Author

Commented:
That worked great!  Thank you....