Please enable JavaScript to view this site.


int = MoonPhaseOf(nDate, nMoonDataSourceIndex, bUseEighths)


This macro function returns a value from 0 to 8 depending on the moon phase that occurs on the date nDate for the moon data source of position nMoonDataSourceIndex.


The parameter bUseEighths specifies if 1/8th phases should be calculated, or only the more common 1/4 phases (left column above).


The possible values returned by this function correspond to:



No moon phase of the type specified on nDate.


New Moon


Waxing Crescent


First Quarter


Waxing Gibbous


Full Moon


Waning Gibbous


Last quarter


Waning Crescent


The meaning of the result 0 depends on the value of the parameter bUseEighths.


If bUseEighths is false (the usual case) then a result of 0 means that there is no occurrence of any of the quarter moon phases on the current date, but it is still possible that an eighth phase occurs on nDate, because we specifically told Q++Studio to ignore the occurrence of eighth phases.

If bUseEighths is true then a result of 0 means that there is no occurrence of any of the quarter moon and no occurrence of any of the eighth phases occurs on nDate.


The macro code below displays the name of the Moon phase, if any, occurring on nDate.

switch MoonPhaseOf(nDate, 1, false)
   case 0
      sRESULT = 'No moon phase on ' + FormatDate('c', nDate)
   case 1
      sRESULT = 'New moon on ' + FormatDate('c', nDate)
   case 3
      sRESULT = 'First quarter on ' + FormatDate('c', nDate)
   case 5
      sRESULT = 'Full moon on ' + FormatDate('c', nDate)
   case 7
      sRESULT = 'Last quarter on ' + FormatDate('c', nDate)

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

To calculate and display the time when a Moon phase occurs, use the function MoonPhaseAndTimeOf.


See also: MoonPhaseAngle, MoonPhaseName, MoonPhaseSymbol.


Topic 110076, last updated on 18-Apr-2020