Please enable JavaScript to view this site.


int = MoonPhaseAngle(nDate, nTimeOfDay, nMoonDataSourceIndex)


This macro function returns the phase angle between the Moon and the Sun on the date nDate at nTimeOfDay for the moon data source of position nMoonDataSourceIndex.


The function returns 10000 times the longitude angle (a result of 27825486 would mean 278.25486 degrees).

The parameter nTimeOfDay should be supplied in one millionth of a day (less than 1/10th of a second), using the function MillionFromHMS to avoid any error.

The parameter bTopocentric determines if the calculation is based on the position of the observer for nMoonDataSourceIndex, otherwise that parameter is only used for the timezone information.


The macro code below checks the status of the Moon and Sun on nRunDate and this information is then used in one of the best day for an activity functions (note how this function can be used to calculate the current phase of the Moon).

nAt2359 = MillionFromHMS(23,59,59)
nLongitude = MoonLongitudeAngle(nRunDate, nAt2359, nIdxSrcZodiac, true)
nZodiac = MoonZodiacSignOf(nRunDate, nAt2359, true, nIdxSrcZodiac) - 1
nMoonPhase = MoonPhaseOf(nRunDate, nIdxSrcPhases, true)
bNewMoon = (nMoonPhase == 1)
bFullMoon = (nMoonPhase == 5)
bIsFirstQuarterDay = (nMoonPhase == 3)
bViertel = (nMoonPhase in [3,7])
nPhase = MoonPhaseAngle(nRunDate, nAt2359, nIdxSrcPhases)
bIn1stQuarter = (nPhase in [      0 ..  899999])
bIn2ndQuarter = (nPhase in [ 900000 .. 1799999])
bIn3rdQuarter = (nPhase in [1800000 .. 2699999])
bIn4thQuarter = (nPhase in [2700000 .. 3599999])
bIncreasingMoon = bIn1stQuarter or bIn2ndQuarter
bDecreasingMoon = bIn3rdQuarter or bIn4thQuarter
if GoodDayFor(sCurActivity)
    if sResult <> ''
        sResult = sResult + ', '
    sResult = sResult + IntToStr(DayOf(nRunDate))

See also: MoonLongitudeAngle, MoonPhaseOf, MoonPhaseAndTimeOf.


Topic 179855, last updated on 18-Apr-2020