Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ale_nilo84
Contributor
Contributor

qvd file without information

Hello everyone,


I have the following script, it works without errors, but it doesn't return any data.

Basically, I connect to an MS Access query and define a Start Date and an End Date to bring information.


the result of the log is:

Connecting to MS Access Database;DBQ=C:\Users\Alexis\Desktop\Qlik\base de datos\Trx.accdb

Connected

trx << 021_Trx_Totales 0 Lines fetched

--- Ejecución de Script finalizada ---

I hope someone can help me. Thank you...

LET vFechaInicioCarga = date(date#(01072018, 'DDMMYYYY'), 'DD-MM-YYYY');

LET vFechaFinCarga = date(MonthEnd(vFechaInicioCarga),'DD-MM-YYYY');

LET vPeriodoCarga = num#(date(vFechaInicioCarga, 'YYYYMM'));

ODBC CONNECT32 TO [MS Access Database;DBQ=C:\Users\Alexis\Desktop\Qlik\base de datos\Trx.accdb];

   

trx:

SQL SELECT

    fecha,

    generico,

    Id,

    sentido,

    servicio,

    "tipo_dia",

    "Trx_Totales",

    unidad,

    variante

FROM "021_Trx_Totales"

where fecha >=$(vFechaInicioCarga) and fecha <=$(vFechaFinCarga);

STORE trx into [..\Qlik\transacciones_$(vPeriodoCarga).qvd];

drop table trx;

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

A SQL statement is - after all $-sign substitution - sent AS-IS to the external SQL engine (in this case a Jet-engine from MS Access) to be decoded and executed. So the hashes can be added wherever you want. The most simple solution is to add them to the SQL statement itself, like:

SQL SELECT

...

FROM "021_Trx_Totales"

WHERE fecha >= #$(vFechaInicioCarga)# AND fecha <= #$(vFechaFinCarga)#;

View solution in original post

14 Replies
Lisa_P
Employee
Employee

It must be related to your conditions.

Try it with just the >= and then with the <= and see what happens.

andrey_krylov
Specialist
Specialist

Maybe to put apostrophes

where fecha >='$(vFechaInicioCarga)' and fecha <='$(vFechaFinCarga)'

Anil_Babu_Samineni

Is fecha field is in DD-MM-YYYY this format ??

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
simospa
Partner - Specialist
Partner - Specialist

Hi,

here some checks:

1. does it works without this row? where fecha >=$(vFechaInicioCarga) and fecha <=$(vFechaFinCarga);

2. on the title you are saying "qvd without data": before the store  you have date in your .qvw ?

3. if the answer to 2. is "yes": did you try to append (qvd) to the store? STORE trx into ..\Qlik\transacciones_$(vPeriodoCarga).qvd (qvd);


Let us know

S.

ale_nilo84
Contributor
Contributor
Author

just using where fecha >=$(vFechaInicioCarga)  save all the information of the query in the qvd

just using where fecha <=$(vFechaFinCarga)  does not save anything in the qvd


ale_nilo84
Contributor
Contributor
Author

using apostrophes the following error appears

ODBC error

Connector reply error: SQL##f - SqlState: 22005, ErrorCode: 4294964266, ErrorMsg: [Microsoft][Controlador ODBC Microsoft Access] No coinciden los tipos de datos en la expresión de criterios.

ale_nilo84
Contributor
Contributor
Author

Yes, it is the format used in Chile

Miguel_Angel_Baeyens

If the values stored in the field "fecha" are in the form DD-MM-YYYY and defined as a date field in the RDBMS you will then need to use SQL date functions to compare, or do it in the LOAD part.

If they instead are defined as literals or strings, then you do need to use single or double quotes Chr(39) or Chr(34) respectively, and use the Text() function in your variables, so the value is stored as a string. Else, according to your script $(vFechaInicioCarga) = -2024 (1 - 7 - 2018). This will work though if you use SET instead of LET.

It looks like that WHERE clause is comparing numbers to strings, which happens to be always false, and that's why you get no data or that "fecha" is indeed numeric but the variables are using a different format, like "-2024" instead of "01-07-2018".

Peter_Cammaert
Partner - Champion III
Partner - Champion III

If I remember correctly, MS Access expects Date values to be formatted as #18/09/2018# (including the hashes)

See: Examples of using dates as criteria in Access queries - Access