| Author |
Date filters Handling
|
|
| ehabaziz2001@gmail.com 2005-10-12, 6:55 pm |
| I have a report based on from to Date Ranges but the filter does not
follow the dates ranges . I do not know why ?
the from variable called : from_d
the to variable called : to_d
a_vars[1]:=""
a_vars[2]:=""
a_vars[3]:=""
a_vars[4]:=""
a_vars[5]:=""
a_vars[6]:=""
a_vars[7]:=""
a_vars[8]:=""
a_vars[9]:=""
a_vars[10]:=""
select 4
a_fields[1]:="pa_ACCt"
a_fields[2]:="pa_START_D"
a_fields[3]:="pa_SERIAL"
a_fields[4]:="pa_MODEL"
a_fields[5]:="pa_brn"
a_fields[6]:="pa_TYPE"
a_fields[7]:="pa_me_res"
a_fields[8]:="pa_cu_ser"
a_fields[9]:="pa_date"
a_fields[10]:="pa_date"
a_vars[1]:=v_me_acct
a_vars[2]:=V_me_START_D
a_vars[3]:=V_me_serial
a_vars[4]:=V_me_MODEL
a_vars[5]:=V_Mc_brn
a_vars[6]:=V_Mc_TYPE
a_vars[7]:=V_Mc_me_res
a_vars[8]:=V_Mc_cu_ser
a_vars[9]:=from_d
a_vars[10]:=to_d
cValue := ""
cValue1 := ""
cValue2 := ""
cFilter := ""
cFilter1 := ""
For i := 1 to 10
IF Empty(a_Vars[i]) .or. empty(a_Fields[i]) && Don't
process empty variables
LOOP
ENDIF
DO CASE && Create char value
CASE VALTYPE(a_vars[i]) == "D" .and. a_vars[i]==V_me_START_D
cValue := 'DTOC(' + a_Fields[i] + ') == "' +
DTOC(a_Vars[i]) + '"'
CASE VALTYPE(a_vars[i]) == "D" .AND. i==9
cValue := 'DTOC(' + a_Fields[i] + ') >= "' +
DTOC(a_Vars[i]) + '"'
CASE VALTYPE(a_vars[i]) == "D" .AND. i==10
cValue := 'DTOC(' + a_Fields[i] + ') <= "' +
DTOC(a_Vars[i]) + '"'
CASE VALTYPE(a_vars[i]) == "N"
cValue := 'STR(' + a_Fields[i] + ') == "' + STR(a_vars[i])
+ '"' && or
* some other NUM->Chr conversion
CASE VALTYPE(a_vars[i]) == "C"
cValue :="alltrim(upper("+ a_Fields[i]+"))" + '=="' +
alltrim(upper(a_Vars[i])) + '"'
ENDCASE
IF Empty(cFilter) && this is the first element
cFilter := cValue
ELSE
cFilter += " .AND. " + cValue
ENDIF
NEXT
set filter to &(cfilter)
go top
NTBRETVAL :=i8dbedit (10,3,23,76,4,MDATABLOCK)
| |
| Stephen Quinn 2005-10-12, 9:55 pm |
| Ehab
You don't strip the final '+' from your string BEFORE you set the filter
Your final filter length may be greater than 250 characters if ALL 10 elements
are used
- IIRC that's about the max you can use in the macro compiler
You may NOT have enough quotes in the final filter value - experiment.
Have you tried viewing some values to see what the result looks like??
eg
CASE VALTYPE(a_vars[i]) == "D" .and. a_vars[i]==V_me_START_D
cValue := 'DTOC(' + a_Fields[i] + ') == "' + DTOC(a_Vars[i]) + '"'
// Print to screen as I know you don't like to use the debugger
? cValue
inkey(0)
You might try DTOS() instead of DTOC() as that is format agnostic.
HTH
Steve
| |
| ehabaziz2001@gmail.com 2005-10-14, 6:55 pm |
| The filter works with DTOS not with DTOC ...... WHY this ?
| |
| AUGE_OHR 2005-10-14, 6:55 pm |
| hi,
> The filter works with DTOS not with DTOC ...... WHY this ?
DTOS() allways return YYYYMMDD as cString
DTOC() depends on SET DATE Format
you also shoud SET EPOCH TO xxxx to be in the right SET CENTURY
greetings by OHR
Jimmy
|
|
|
|