# Calculating Julian dates

I need to calculate the Julian date of a date using server side vbscript.
Is there perhaps a function or any other way of doing this?
###### Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x

Commented:
Ok, I don't have any idea about what Julian date is. I Just make this script using the formula i found around. If you want to know what this means you must refer to this page (there are a lot more around).

xabi
0

Commented:
Hi there:

Try this:

<%
y = year(now())
m = month(now())
d = day(now())
uh = hour(now())
um = minute(now())
us = second(now())
extra = 100.0*y + m - 190002.5
rjd = 367.0*y
rjd = rjd - int(7.0*(y+int((m+9.0)/12.0))/4.0)
rjd = rjd + int(275.0*m/9.0) + d
rjd = rjd + (uh + ((um + us/60.0)/60.)/24.0) + 1721013.5
rjd = (rjd - 0.5*extra/abs(extra)) + 0.5
Response.Write(rjd)
%>

This will calculate julian day for now. If you want to calculate it for other moment just change the first 6 lines

xabi
0

Commented:
Better use this other one:

<%
ye = 200
mo = 1
da = 19
ho = 12
mi = 12
se = 12
univTime = ho+(mi/60)+(se/3600)
if ((100*ye+mo-190002.5) >= 0) then
sign = 1
else
sign = -1
end if
jd = (367 * ye) - (int((7*(ye+int((mo+9)/12)))/4)) + (da+int((275*mo)/9)) + (1721013.5+(univTime/24)) - (0.5*sign) + 0.5
Response.Write(jd)
%>

xabi
0

Author Commented:
I tried both pieces of code and here are the results.

1. 2451572.52136574
2. 1794114.0084722

I'm not sure what these values mean??
0

Commented:
Yes I know, that's cause i said you to use second one. I had a mistake in the first one and when you give an answer you can give another.

xabi.

PS: Use second one. I tested it comparing its results with two other programs.
0

Author Commented:
I did try the second piece on code and this is answer it gave:
1794114.0084722

I'm not what this large number means.
I'm not sure but is Julian date not suppose to give you the day number in a year?
I'll appreciate it if you can explain this as well as the large number produced from the second piece of code.
0