Calculate phases of the moon
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
|