Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Between 2 dates
Message
From
13/11/2023 20:11:53
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Between 2 dates
Miscellaneous
Thread ID:
01687236
Message ID:
01687236
Views:
69
Hi,

I have the following problem, because the command don´t return records between my 2 dates:
LOCAL lcDBFFile AS STRING, lnSQLHand AS INTEGER, ;
    lcSQLCmd AS STRING, lnSuccess AS INTEGER, ;
    lcConnstr AS STRING
CLEAR

lcDBFFile = [D:\1.Bnext_Espanha\Orozco\EMP01\EMP01\gestion.dbc]

*!*	lcConnstr = [Driver={Microsoft dBASE Driver (*.dbf)};] + ;
*!*	    [SourceType=DBF;] + ;
*!*	    [SourceDB=] + lcDBFFile
    
lcConnstr = "Driver={Microsoft Visual FoxPro Driver};" + ;
      "SourceType=DBC;" + ;
      "SourceDB= " + lcDBFFile + ";" + ;
      "Exclusive=No"; 

IF !FILE(lcDBFFile)
    ? [DBF file not found]
    RETURN .F.
ENDIF

lnSQLHand = SQLSTRINGCONNECT(lcConnstr)

Local FECHA, FECHA1

FECHA = CTOD(PDU_6QQ0XQG2Y.pageframe1.page1.obj8.text)  && the value here is : 06.11.2023


lcSQLCmd = [SELECT * FROM DOCUMENTOS WHERE  ( FECHA BETWEEN DATE(Year(FECHA), Month(FECHA), Day(FECHA)) and DATE(Year(date()), Month(date()), Day(date())) ) ;
 and  tipodocu = 'F' And  !DELETED() ORDER BY ID_ISO, FECHA, numdocu ASC ]

lnSuccess = SQLEXEC(lnSQLHand, lcSQLCmd, [xlResults])
? [SQL Cmd Success:], IIF(lnSuccess > 0, 'Good!', 'Failed')
IF lnSuccess < 0
    LOCAL ARRAY laErr[1]
    AERROR(laErr)
    ? laErr(3)
    SQLDISCONNECT(lnSQLHand)
    RETURN .F.
ENDIF

* Show the results
SELECT xlResults
BROWSE NOWAIT
SQLDISCONNECT(lnSQLHand)
the cursor return all dates from 02.01.2021 to 06.11.2023 !!??

Why ?

I need only records between 06.11.2023 and today : 14.11.2023.

anyone could help me to understand what are doing wrong?

thanks
Luis
Next
Reply
Map
View

Click here to load this message in the networking platform