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.

 

This function combines sequences of at least three consecutive day numbers; two consecutive days remain separate. For example, '1,3,4,6,7,8,9,12' becomes '1,3,4,6-9,12'.

 

•This function expects day numbers from 1 to 31 without leading zeros, already in ascending order within each sequence, separated by exactly sDateSeparator.

•This function does not sort the input.

•Sequences in which each day is followed by an asterisk are also supported. For example, '1*,2*,3*' becomes '1-3*' when the separators are a comma and a hyphen.

•The legacy implementation searches for sequences of 3 to 16 days. Longer runs are not reliably formatted as a single range: with comma-separated input and a hyphen as sConcatChar, days 1 through 17 become '1,2-17', while days 1 through 31 can become '1-16-31'.

•Repeated occurrences of the same sequence may also remain uncombined.

 

Use the extended function StrDatesConcatenateEx to handle leading zeros, a separate separator for two-day runs, optional sorting, or runs longer than 16 days.

 

➢Note that in some cases you can use holidays multiple options to achieve the same result as the use of a macro and this function.

 

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 + ', '
        endif
        sResult = sResult + IntToStr(DayOf(nRunDate))
    endif
endfor
// once we have all the best days of the month
if sResult == ''
    sResult = 'NO GOOD DAYS'
    bResult = false
else
    sResult = StrDatesConcatenate(sResult,', ','-')
    bResult = true
endif

See also: faBestDayFor, StrDatesConcatenateEx.

 


Topic 178905, last updated on 11-Oct-2026