Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
somi
Contributor
Contributor

SQL: Data of the last 7 days

Hello all,

I would like to filter all data in the script (SQL) by a date. I want all the data that was created in the last 7 days.

I searched a little in the forum, unfortunately my solution does not work....

Can someone help me?

SET DateFormat='DD.MM.YYYY';
SET TimestampFormat='DD.MM.YYYY hh:mm:ss[.fff]';

LOAD "rechnung_dbid",  "beleg_date";
SQL SELECT "rechnung_dbid", "beleg_date"
FROM pdserp."public"."pds_rechnung"
WHERE Interval(Date#($(TodayDate), 'DD.MM.YYYY') - Date#("beleg_date", 'DD.MM.YYYY'), 'DD') < 7;

Thanks Many greetings
Martin

1 Reply
Thiago_Justen_

Hi there, try this out:

SET DateFormat='DD.MM.YYYY';
SET TimestampFormat='DD.MM.YYYY hh:mm:ss[.fff]';

Let vFilterDate = Date(today()-7);

LOAD "rechnung_dbid",  "beleg_date";
SQL SELECT "rechnung_dbid", "beleg_date"
FROM pdserp."public"."pds_rechnung"
WHERE Num(beleg_date) > '$(vFilterDate)' ;

Regards

Thiago Justen Teixeira Gonçalves
Farol BI
WhatsApp: 24 98152-1675
Skype: justen.thiago