I wish found the first( primo) and the last ( ultimo) on a Interval of years
the records go from 1871 to 2024 and there are 10538 records
![Image](https://i.postimg.cc/pyN29qJ7/s.png)
the fourth parameter is not true as it should be 3549 as you can see here
![Image](https://i.postimg.cc/R0PJ3x6D/db.png)
I set the interval of years I made
Code: Select all | Expand
#include "FiveWin.ch"
REQUEST DBFCDX
Function SetAnno()
LOCAL aSetAnno := {}
LOCAL primo, ultimo, ntotali_records
LOCAL oDbf
LOCAL nAnno1 := "1939"
LOCAL nAnno2 := LTrim(Str(Year(Date()))) // year now
// Apre il database
oDbf := TDatabase():Open( , "Lotto", "DBFCDX", .T. )
IF oDbf == NIL
MsgInfo("Errore nell'aprire il database!", "Errore")
RETURN NIL
ENDIF
oDbf:SetOrder(1)
oDbf:GoTop()
Select( oDbf:nArea ) // for use locate
ntotali_records := oDbf:OrdKeyCount()
LOCATE FOR Year(oDbf:data) = Val(nAnno2)
oDbf:load()
IF oDbf:Found()
LOCATE FOR Year(oDbf:data) != Val(nAnno2)
IF oDbf:Found()
ultimo := oDbf:RecNo() - 1
ELSE
ultimo := oDbf:LastRec()
ENDIF
ELSE
ultimo := oDbf:LastRec()
ENDIF
LOCATE FOR Year(oDbf:data) = Val(nAnno1)
oDbf:load()
IF oDbf:Found()
primo := oDbf:RecNo()
ELSE
primo := 1
ENDIF
AAdd(aSetAnno, {nAnno1, nAnno2, ntotali_records, primo, ultimo})
XBrowser aSetAnno
oDbf:End()
RETURN NIL
give me allways the first record of archive (1871) and not the first of 1939
how I can resolve ?