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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
ashmitp869
Creator II
Creator II

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

Labels (1)
1 Solution

Accepted Solutions
MayilVahanan
MVP
MVP

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
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

1 Reply
MayilVahanan
MVP
MVP

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
Please close the thread by marking correct answer & give likes if you like the post.