Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us at the Cloud Data and Analytics Tour! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
ashmitp869
Contributor III
Contributor III

Script error with latest extract date

Hi there ,

I am getting an error in qlikview script like below image -

 

7.PNG

 

My qlikview script :

SQL
SELECT
CAST(max([StartDateTime]) AS DATE) AS LATEST_EXTRACT
FROM "TEST".dbo.[view_test]
where [Id] in ('aaa','vv','cc');



LET vExtractDate = Num(Peek('LATEST_EXTRACT', 0, 'EXTRACT_DATE'));

SQL SELECT *
FROM "TEST".dbo.[view_test]
where [Id] in ('aaa','vv','cc')
and DATEFROMPARTS(YEAR([StartDateTime]), MONTH([StartDateTime]),DAY([StartDateTime]))>=DATE($(vExtractDate) - 366)

 

 

ashmitp869_1-1620021957215.png

 

 

the requiement is to load the data greater than the LATEST_EXTRACT date.

 

 

Regards

1 Solution

Accepted Solutions
MayilVahanan

Hi @ashmitp869 

In SQL, there is no built function like "Date". You need to use DateAdd() function, like below

DATEFROMPARTS(YEAR([StartDateTime]), MONTH([StartDateTime]),DAY([StartDateTime]))>=

Cast(DATEAdd(Day, -366,$(vExtractDate)) as Date);

 

Thanks & Regards,
Mayil Vahanan R

View solution in original post

1 Reply
MayilVahanan

Hi @ashmitp869 

In SQL, there is no built function like "Date". You need to use DateAdd() function, like below

DATEFROMPARTS(YEAR([StartDateTime]), MONTH([StartDateTime]),DAY([StartDateTime]))>=

Cast(DATEAdd(Day, -366,$(vExtractDate)) as Date);

 

Thanks & Regards,
Mayil Vahanan R

View solution in original post