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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources 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

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

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