60 * 60 * 1000 - 3600000 miliseconds in one Hour
60 * 60 * 1000 * 24 = 86400000 miliseconds in one Day
86400000 * 364 = 31536000000 miliseconds in one Year
You know you will always have a two day difference because the moon never rises and sets in the same day.
Day(1) MoonRise = 9 AM
Day(2) MoonSet = 12am
Convert Day 1 and 2 into a 24 hour scale
Function CheckForPM(Hour as Int,M as String)
If M = "PM" Then
CheckForPM = Moon + 12
End If
End Function
MoonRise = CheckForPM(9,"AM")
MoonSet = CheckForPM(12,"AM")
Now convert them into a base 10 time by converting them into miliseconds.
Function ConvertToBase10(Hours as int)
ConvertToBase10 = 60 * 60 * 1000 * Hours
End Function
MoonRise = ConvertToBase10(MoonRise)
MoonSet = ConvertToBase10(MoonSet)
You should have a nice number to work with which represents the time of day in miliseconds. Now the easiest way to figure out the difference is to know the day which is available via HS scripting or you can extract the day from the internet if you prefer. But you need to get the day to make this simple.
MoonRise = 32400000
MoonSet = 43200000
You can use VB Scripts built in date function to get your computers system date and time.
CurrentDate = Date(milliseconds) This will give you the date in milli seconds since January 1st 1970 at midnight. So for every 31536000000 milliseconds in your answer is how many years its been since 1970. So this year is 1103760000000(2005) and we are on our 74 day of the year. (74 * 86400000) = Number of milliseconds in this year. Add the to the number of years milliseconds and you get the exact date in milliseconds.
86400000 + 1103760000000 = 1103846400000(Exact Date in milliseconds)
Now add your Time of MoonRise in milliseconds to the date(Which was given to you by the date(milliseconds function) and you will get you time that the moon rose on that specific date. Then when the moon sets the next day or on the same day you can get the date from your system again and do the same math. Now subtract the first number from the second to get the difference. Then devide by the number of milliseconds in a day to get the hour difference.
I'm sure with all this typing i proabably have missed something but what I am trying to say here is that there is a way to do it but you need more information. Either you need to know that the moon will set atleast after 11:59am the same day or you need to know the date.
Either way here is a good site that will teach you all about the date and time functions and what you can do to manipulated the date and time.
Edit sorry this link is for JavaScript but i think vbscript has the same function so i will leave the link here
http://www.devguru.com/Technologies/ecmasc...ckref/date.html