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