Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sql select for each day

Hi all,

i have a select like this :

sql select table.name, table.surname, table.age

from table

where table.borndate = vDday

I need vDay loops between 2 values(i.e. 20120101 and sysdate)

Result set will be a list of record for each day

tyvm

Simone

19 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Si ma il formato è DD/MM/YYYY? se è così allora dovrebbe già fiunzionare, altrimenti prova

a girare le date

num(Date#('01/02/2014','DD/MM/YYYY')) in ..... YYYY/MM/DD


Num(Date#(Today(),'DD/MM/YYYY') in YYYY/MM/DD


Dovrebbe andare, fammi sapere

Not applicable
Author

you can try

where borndate =   '$(vYourVariable)'

Not applicable
Author

Il formato su db è dd/mm/yyyy

l'errore restituito quando lancio lo script è

ORA-00932: tipi di dati incoerenti: previsto DATE, ottenuto NUMBER

LET myDateIni = Num(Date#('01/02/2013','DD/MM/YYYY'));

LET myDateFin = Num(Today());

FOR i = num(Date#('01/02/2013','DD/MM/YYYY')) to Num(Date#(Today(),'DD/MM/YYYY'))

  SELECT * from employee_uo where start_date = $(i);

NEXT

alexandros17
Partner - Champion III
Partner - Champion III

Ciao Simone,

La mia query gira in MSSQL, la tua in oracle, quando ci sono problemi di formato dovuti al DB, fai lavorare qlik, prova a spostare la logica nel load in questa maniera e fammi sapere

FOR i = num(Date#('01/02/2014','DD/MM/YYYY')) to Num(Date#(Today(),'DD/MM/YYYY))

      LOAD * where Num(borndate) = $(i);

     SELECT * from myTable;

NEXT

Not applicable
Author

continua a darmi errore, con l'ultima soluzione non trova il campo borndate.

sto impazzendo per un cosa che in teoria dovrebbe essere semplice

Grazie

Simone

Not applicable
Author

hi Bill

i tried this way :

FOR i = Date#('01/12/2012','DD/MM/YYYY') to Date#('31/12/2012','DD/MM/YYYY')

SELECT cod_uo, employee_id

  FROM employee_uo

WHERE $(i) >= start_date AND $(i) <= expiry_date;

NEXT;

Lookup Error ORA-00932: inconsistent datatypes: expected DATE got NUMBER

SELECT cod_uo, employee_id

  FROM employee_uo

WHERE 41244 >= start_date AND 41244 <= expiry_date

Any solution?

tyvm

maxgro
MVP
MVP

this works on an oracle dbms

hiredate is a date data type in my table

OLEDB CONNECT32 TO [Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=xxxx;Data Source=xxxxx;Extended Properties=""] (XPassword is xxxxxxxxxxxxx);

LET myDateIni = Num(Date#('01/01/2014','DD/MM/YYYY'));

LET myDateFin = Num(Today());

FOR i = myDateIni to myDateFin

  TRACE $(i);

  LET d=date($(i), 'DD/MM/YYYY');

  trace $(d);

  LOAD *; 

  SQL SELECT * FROM "TEST"."EMP" where hiredate >= to_date('$(d)', 'DD/MM/YYYY');

NEXT

Not applicable
Author

let vint=interval(Date1-Date2,'D')

For i =0 to vint

let Vdate=dayname('Date1',$(i))

SELECT cod_uo, employee_id

  FROM employee_uo

WHERE vdate >= start_date AND vdate <= expiry_date;

NEXT

Not applicable
Author

Try below...

sql select table.name, table.surname, table.age

from table

where table.borndate >='$(vDday)' and table.borndate <=Today()

maxgro
MVP
MVP

stai confrontando la start_date che sul db oracle è una date con la variabile qlikview che contiene un numero, da cui l'errore oracle, cioè stai eseguendo qualcosa di simile a 

SELECT * from employee_uo where start_date = 40000;