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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

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

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
      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

gfactorAuthor 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??
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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.


PS: Use second one. I tested it comparing its results with two other programs.
gfactorAuthor Commented:
I did try the second piece on code and this is answer it gave:

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.
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).


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.