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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
TeodoraBurlica
Partner - Contributor III
Partner - Contributor III

Last 4 hours

Hi, 

I want to calculate last 4 hours in script, but it's not working. I have the following expressions:

MinMaxDate:

LOAD 

Max(TimeStamp(STAMP)) as MaxDate

Resident Table;

LET vMaxDate = peek ('MaxDate', 0, 'MinMaxDate');

FilterCalendar:

LOAD distinct 

STAMP

Resident Table

Where $(vMaxDate) - timestamp(STAMP) <4/24;

Any ideas?

Labels (1)
1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

It all depends on how the data looks...

But the most probable cause, is that vMaxDate is formatted as a timestamp, and then your dollar expansion will cause problems:
... Where $(vMaxDate) - timestamp(STAMP) <4/24;
probably expands to something like
... Where 2022-06-20 13:14:15 - timestamp(STAMP) <4/24;
which will give an error.

Try single quotes:
... Where '$(vMaxDate)' - STAMP <4/24;

View solution in original post

2 Replies
hic
Former Employee
Former Employee

It all depends on how the data looks...

But the most probable cause, is that vMaxDate is formatted as a timestamp, and then your dollar expansion will cause problems:
... Where $(vMaxDate) - timestamp(STAMP) <4/24;
probably expands to something like
... Where 2022-06-20 13:14:15 - timestamp(STAMP) <4/24;
which will give an error.

Try single quotes:
... Where '$(vMaxDate)' - STAMP <4/24;

TeodoraBurlica
Partner - Contributor III
Partner - Contributor III
Author

It works! Thank you