int = chDateSolarTermOnOrBefore(nWesternDate)
This macro function returns the date of the most recent Chinese solar term on or before nWesternDate.
The example below displays the dates of the two solar terms in the western month and year supplied as input.
input
nWesternMonth nWesternYear
var
nMidMonth nEndMonth
nDateMinorTerm nDateMajorTerm
begin
// minor term is around the 5th of each month
nMidMonth = EncodeDate(nWesternYear, nWesternMonth, 15)
nDateMinorTerm = chDateSolarTermOnOrBefore(nMidMonth)
// major term is around the 21st of each month
nEndMonth = EncodeDate(nWesternYear, nWesternMonth, 28)
nDateMajorTerm = chDateSolarTermOnOrBefore(nEndMonth)
// display the 2 solar term dates as text
sResult = 'Minor term on = ' + FormatDate('ddd d', nDateMinorTerm)
sResult = sResult + chr(13) // break to next line
sResult = sResult + 'Major term on = ' + FormatDate('ddd d', nDateMajorTerm)
end
The above example relies on the fact that there are never more than 2 solar terms for any given western month, and that the minor term usually occurs around the 5th of each month, and the major term around the 21st of each month (plus or minus 2 days).
See also: chDateSolarTermOnOrAfter, chinese dates functions.
Topic 176710, last updated on 11-Oct-2026