Please enable JavaScript to view this site.


int = MoonPhaseAndTimeOf(nDate,nMoonSourceIndex,bUseEighths)


This macro function returns the index and time of the Moon phase that occurs on nDate.


The result is the time of the day expressed in one millionth of a day (less than 1/10th of a second).


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.


To separate the index and time, use the div and mod functions on the returned result, as shown in the code below.

nMoonIndex = 0
nPhaseAndTime = MoonPhaseAndTimeOf(nRunDate,1,false)
// do we have a phase ?
if (nPhaseAndTime > 0)
   nMoonIndex = nPhaseAndTime div 1000000
   nMoonTime = nPhaseAndTime mod 1000000

The macro code below uses HeliacalEventOnDate in conjunction with MoonPhaseAndTimeOf, to look for the Maori New Year (Matariki), which corresponds to the new Moon which follows the heliacal rise of the Pleiades star cluster.

nEventType = 1 // heliacal rise
nAstroBody = 29 // Alcyone, the brightest star in the Pleiades
// look from mid-May to the end of June
nHeliacalDate = 0
for nRunDate = EncodeDate(nYear,5,15to EncodeDate(nYear,6,30)
   nHeliacalTime = HeliacalEventOnDate(nRunDate,1,nAstroBody,nEventType)
   if nHeliacalTime >= 0
      nHeliacalDate = nRunDate
      break // found it
Assert(nHeliacalDate > 0'heliacal event not found', true)
// now look for the new Moon that follows
nMatarikiDate = 0
for nRunDate = nHeliacalDate to EncodeDate(nYear,6,30)
   nNewMoonTime = MoonPhaseAndTimeOf(nRunDate,1,false)
   // do we have a phase and if so a new Moon ?
   if (nNewMoonTime > 0and (nNewMoonTime div 1000000 == 1)
      // if the new Moon is on the exact date of the heliacal rise
      // make sure that the time of the new Moon is after it
      if nRunDate == nHeliacalDate
         // New Moon must be after heliacal rise
         if (nNewMoonTime mod 1000000) > nHeliacalTime
            nMatarikiDate = nRunDate
            break // found it
            // too early keep looking for the next new Moon
         nMatarikiDate = nRunDate
         break // found it
Assert(nMatarikiDate > 0'Matariki not found', true)
// at the end
sResult = 'Maori New Year on ' + FormatDate('Dddd, Mmmmm d, yyyy', nMatarikiDate)

See also: MoonPhaseName and MoonPhaseSymbol.


Topic 177660, last updated on 18-Apr-2020