Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
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