Subject: @Explode( dateRange ) - a challenge
Having spent some time on this and played around a bit I have come up with the following:
Use a post open event to set a “date format” flag…
Sub Postopen(source As Notesuidocument)
If source.IsNewDoc Then
'only run through the field setting if this is a new document...
Dim session As New NotesSession
Dim international As NotesInternational
Set international = session.International
If international.IsDateDMY Then
Call doc.ReplaceItemValue("DatesStyleFlag", "DMY")
Elseif international.IsDateMDY Then
Call doc.ReplaceItemValue("DatesStyleFlag", "MDY")
Elseif international.IsDateYMD Then
Call doc.ReplaceItemValue("DatesStyleFlag", "YMD")
Else
Call doc.ReplaceItemValue("DatesStyleFlag", "UNKNOWN")
End If
Call source.Refresh
End If
End Sub
Then this formula then computes the range based on the format set in postOpen. Except for a little tidying up, I think it’s about the best soloution I’m going to be able to dream up, but any alternatives are still welcome…
REM {Only build up the range where the field will not exceed 32K limit} ;
REM {n.b. we’re not really near the 32K limit, just keep small for better performance } ;
REM {NOTE: The DatesStyleFlag field is set in the postOpen event} ;
@If( DoDateRange = “Yes” ;
"" ; @Return("")) ;
REM {Day Month Year ---------------------------------------------------------------------------------------------------} ;
sDateDMY := @Right(“00” + @Text(@Day(StartDate)); 2) + “/” +
@Right("00" + @Text(@Month(StartDate)); 2) + "/" +
@Text(@Year(StartDate)) ;
eDateDMY := @Right(“00” + @Text(@Day(EndDate)); 2) + “/” +
@Right("00" + @Text(@Month(EndDate)); 2) + "/" +
@Text(@Year(EndDate)) ;
REM {Month Day Year ---------------------------------------------------------------------------------------------------} ;
sDateMDY := @Right(“00” + @Text(@Month(StartDate)); 2) + “/” +
@Right("00" + @Text(@Day(StartDate)); 2) + "/" +
@Text(@Year(StartDate)) ;
eDateMDY := @Right(“00” + @Text(@Month(EndDate)); 2) + “/” +
@Right("00" + @Text(@Day(EndDate)); 2) + "/" +
@Text(@Year(EndDate)) ;
REM {Year Month Day ---------------------------------------------------------------------------------------------------} ;
sDateYMD := @Text(@Year(StartDate)) + “/” +
@Right("00" + @Text(@Month(StartDate)); 2) + "/" +
@Right("00" + @Text(@Day(StartDate)); 2) ;
eDateYMD := @Text(@Year(EndDate)) + “/” +
@Right("00" + @Text(@Month(EndDate)); 2) + "/" +
@Right("00" + @Text(@Day(EndDate)); 2) ;
sDate := @If( DatesStyleFlag = “DMY” ; sDateDMY ;
DatesStyleFlag = "MDY" ; sDateMDY ;
DatesStyleFlag = "YMD" ; sDateYMD ;
"" ) ;
eDate := @If( DatesStyleFlag = “DMY” ; eDateDMY ;
DatesStyleFlag = "MDY" ; eDateMDY ;
DatesStyleFlag = "YMD" ; eDateYMD ;
"" ) ;
date := @Eval( “@Explode( [” + sDate + “-” + eDate + “] )” ) ;
@If( @IsError(date) ; “” ; @TextToTime(@Text(date; “S0”)) )