View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Calculate phases of the moon

Chuck,

There is a page at the Naval Observatory:

http://aa.usno.navy.mil/data/docs/MoonPhase.php#y2009

I just picked two from early this year, and adjusted UTC to EST.

HTH,
Bernie
MS Excel MVP


"Chuck" wrote in message ...
On Wed, 25 Mar 2009 22:43:23 -0400, "Bernie Deitrick" <deitbe @ consumer dot
org wrote:

Bernie,

Thank you. Exactly what I was looking for. Out of curiosity, how did you
arrive at the two reference days? However, now that I have the reference days,
I should be able to calculate the new moons indefinitely on into the future.

Chuck


Chuck,

The code below doesn't take into account the variability of the lunar orbit,
but it is close. It also doesn't take into account DST, which might flip a
day here or there when the actual times are near midnight.

HTH,
Bernie
MS Excel MVP


Dim D1 As Date
Dim D2 As Date
Dim strMsg As String
Dim CurDate As Date
'Average Revolution = 29.5305556 days = 29 days & 12 hrs & 44 minutes
Const RL = 29.5305556

Sub ShowMoonDates()
D1 = DateValue("Jan 26, 2009") + TimeValue(" 2:55:00") ' Reference Date
for New MOON, EST
D2 = DateValue("Feb 9, 2009") + TimeValue("9:49:00") ' Reference Date
for Full MOON, EST
CurDate = Date
On Error GoTo ErrHandler
strMsg = "Dates not corrected for Daylight savings time." & vbCrLf
While D1 <= CurDate
D1 = D1 + RL
Wend 'Next New moon
While D2 <= CurDate
D2 = D2 + RL
Wend 'next Full Moon

strMsg = strMsg + "Next new moon will be on " & Format(D1, "mmm dd,
yyyy") & vbCrLf
strMsg = strMsg + "Next full moon will be on " & Format(D2, "mmm dd,
yyyy")
ErrHandler:
MsgBox strMsg, vbExclamation, "Moon Dates"
End Sub



"Chuck" wrote in message
. ..
Is there an equation that will calculate the phases of the moon?

Chuck