I used to think that functions couldn't be used to Pass SQL because thats what I've allways been told by Seagate(I haven't asked Crystal Decisions Yet) here is one of the formulas that I use for record selection against a SQL Server Datebase that passes SQL 100% and you'll notice there are several of those functions we've all been told won't but they do.
Paul Ellsworth
if IsDatetime({?EndDate}) then
DatetimeValue({?EndDate})+1
else
if uppercase({?EndDate}) = 'TODAY' then (currentdate+1) else
if uppercase({?EndDate}) = 'YESTERDAY' then (currentdate+1) - 1 else
if uppercase({?EndDate}) = 'TOMORROW' then (currentdate+1) + 1 else
if uppercase({?EndDate}) = 'FIRSTOFMONTH' then minimum(MonthToDate)+1 else
if uppercase({?EndDate}) = 'ENDOFMONTH' then DateAdd ("m", 1,minimum(MonthToDate)) else
if uppercase({?EndDate}) = 'FIRSTOFLASTMONTH' then minimum(LastFullMonth)+1 else
if uppercase({?EndDate}) = 'ENDOFLASTMONTH' then maximum(LastFullMonth)+1 else
if uppercase({?EndDate}) = 'FIRSTOFYEAR' then minimum(YearToDate)+1 else
if uppercase({?EndDate}) = 'ENDOFYEAR' then DateAdd ("yyyy", 1,minimum(YearToDate)) else
if uppercase({?EndDate}) = 'FIRSTOFLASTYEAR' then minimum(LastYearYTD)+1 else
if uppercase({?EndDate}) = 'ENDOFLASTYEAR' then minimum(YearToDate) else
if uppercase({?EndDate}) = 'SUNDAY' then
if DayOfWeek(currentdate+1) = 1 then (minimum(WeekToDateFromSun)-6) else minimum(WeekToDateFromSun)+1 else
if uppercase({?EndDate}) = 'MONDAY' then
if DayOfWeek(currentdate+1) <= 2 then (minimum(WeekToDateFromSun)-5) else minimum(WeekToDateFromSun)+ 2 else
if uppercase({?EndDate}) = 'TUESDAY' then
if DayOfWeek(currentdate+1) <= 3 then (minimum(WeekToDateFromSun)-4) else minimum(WeekToDateFromSun)+ 3 else
if uppercase({?EndDate}) = 'WEDNESDAY' then
if DayOfWeek(currentdate+1) <= 4 then (minimum(WeekToDateFromSun)-3) else minimum(WeekToDateFromSun)+ 4 else
if uppercase({?EndDate}) = 'THURSDAY' then
if DayOfWeek(currentdate+1)<= 5 then (minimum(WeekToDateFromSun)-2) else minimum(WeekToDateFromSun)+ 5 else
if uppercase({?EndDate}) = 'FRIDAY' then
if DayOfWeek(currentdate+1)<= 6 then (minimum(WeekToDateFromSun)-1) else minimum(WeekToDateFromSun)+ 6 else
if uppercase({?EndDate}) = 'SATURDAY' then
if DayOfWeek(currentdate+1)<= 7 then (minimum(WeekToDateFromSun)) else minimum(WeekToDateFromSun)+ 7 else
if uppercase(left({?EndDate},5)) = 'TODAY' then
if length({?EndDate}) > 6 and NumericText(right({?EndDate},length({?EndDate})-6)) then
if mid({?EndDate},6,1) = '+' then
(currentdate+1) + tonumber(right({?EndDate},length({?EndDate})-6))
else
if mid({?EndDate},6,1) ='-' then
(currentdate+1) - tonumber(right({?EndDate},length({?EndDate})-6))
else
(currentdate+1)
else
(currentdate+1)
else
if uppercase(left({?EndDate},8)) = 'TOMORROW' then
if length({?EndDate}) > 9 and NumericText(right({?EndDate},length({?EndDate})-9)) then
if mid({?EndDate},9,1) = '+' then
(currentdate+1) + tonumber(right({?EndDate},length({?EndDate})-9)) + 1
else
if mid({?EndDate},9,1) ='-' then
(currentdate+1) - tonumber(right({?EndDate},length({?EndDate})-9)) + 1
else
(currentdate+1)
else
(currentdate+1)
else
if uppercase(left({?EndDate},9)) = 'YESTERDAY' then
if length({?EndDate}) > 10 and NumericText(right({?EndDate},length({?EndDate})-10)) then
if mid({?EndDate},10,1) = '+' then
(currentdate+1) + tonumber(right({?EndDate},length({?EndDate})-10)) - 1
else
if mid({?EndDate},10,1) ='-' then
(currentdate+1) - tonumber(right({?EndDate},length({?EndDate})-10)) - 1
else
(currentdate+1)
else
(currentdate+1)
else
(currentdate+1)