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 possible values returned by this function correspond to:

 

0

No moon phase of the type specified on nDate.

1

New Moon

2

Waxing Crescent

3

First Quarter

4

Waxing Gibbous

5

Full Moon

6

Waning Gibbous

7

Last quarter

8

Waning Crescent

 

The bUseEighths parameter is used as follows:

 

•If bUseEighths is false, then only the four main phases are considered: New Moon (1), First Quarter (3), Full Moon (5), and Last Quarter (7).

•If bUseEighths is true, the intermediate phases (2, 4, 6, and 8) are also considered. This is an extremely rarely used setting.

 

The indices are not renumbered when bUseEighths is false. A result of 0 means that none of the selected phases occurs on nDate.

 

Examples

 

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

The following example distinguishes phase events occurring on nRunDate from the Moon's phase at a particular time.

 

•MoonPhaseOf identifies phase events on the date.

•MoonPhaseAngle determines the quarter and waxing or waning status at the requested time.

 

This is an excerpt from a larger macro used for the Farmers' Almanac. GoodDayFor is an application-specific user-defined function whose implementation is not included here.

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 + ', '
    endif
    sResult = sResult + IntToStr(DayOf(nRunDate))
endif

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 11-Oct-2026