Please enable JavaScript to view this site.


str = StrDatesConcatenate(sDateString, sDateSeparator, sConcatChar)


This macro function takes in a string sDateString containing a series of numbers, each separated by sDateSeparator, and returns a string where consecutive numbers are concatenated using sConcatChar.


For example, the string '1,3,4,6,7,8,9,12' would be returned as '1,3,4,6-9,12'.


The macro code below looks for the best days for a particular activity (such as planting above ground crops), over a month's period, and then uses the function StrDatesConcatenate to shorten the resulting set of dates, as shown in the image above.

nAt2359 = MillionFromHMS(23,59,59)
sResult = ''
sCurActivity = s_TokenRoot // tokens are formed as [1*1ActivityName]
nStartDate = FirstDateOfMonth(n_TokenYear, n_TokenMonth)
nEndDate = LastDateOfMonth(n_TokenYear, n_TokenMonth)
for nRunDate = nStartDate to nEndDate
    if faBestDayFor(sCurActivity, nRunDate, nAt2359, nIdxSrcMoon)
        if sResult <> ''
            sResult = sResult + ', '
        sResult = sResult + IntToStr(DayOf(nRunDate))
// once we have all the best days of the month
if sResult == ''
    sResult = 'NO GOOD DAYS'
    bResult = false
    sResult = StrDatesConcatenate(sResult,', ','-')
    bResult = true

See also: faBestDayFor.


Topic 178905, last updated on 18-Apr-2020