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: 
Anonymous
Not applicable

Variable for past 24 hours

Hi Friends,

I am using the below script for creating a variable for Previous day's date.

LET varPreviousDay = '(' & DayName(DayStart(today()-1)) & ')';

Please someone help me with script for creating a variable - Past 24 Hours.

15 Replies
Gysbert_Wassenaar

LET v24HoursAgo = now()-1;


talk is cheap, supply exceeds demand
tresesco
MVP
MVP

May a bit simpler:

LET varPreviousDay = '(' & DayName(today()-1) & ')';

Not applicable
Author

Not as cleans as Gysberts but the same principle

LET v24H = date(now()-1)&' '& time(now())

simospa
Partner - Specialist
Partner - Specialist

My opinion too :

LET v24HoursAgo = Date(now()-1, 'MM/DD/YYYY hh:mm:ss');

if you want to see the timestamp...

S.

Anonymous
Not applicable
Author

Thanks for the prompt replies friends.

I have a column of TimeStamps like below.

5/12/2015 1:20:02 PM

5/11/2015 11:30:05 PM

.

.

.

.

etc.,

I am trying to select dates (timestamps) for the tickets created in last 24 hours.

I tried LET varPreviousDay = '(' & DayName(DayStart(today()-1)) & ')'; and the result is it is selecting 5/12/2015 tickets.

But I want to select the last 24 hours. The current time of mine is now 5/13/2015 2:55 PM IST.

I want to select the date / time stamps for last 24 hours like 5/12/2015 2:55 PM IST to 5/13/2015 2:55 PM IST.

Not applicable
Author

Hi,

Setup an expression where you only show the values that are bigger then your set variable time stamp and you should get the correct behavior.

Anonymous
Not applicable
Author

Hampus, Sorry for asking. I am not able to understand. I have tried the last response received LET v24HoursAgo = Date(now()-1, 'MM/DD/YYYY hh:mm:ss'); and it is showing the variable result as time stamp before 24 hours. But when I am using this variable in a button. it is looking for the entry at that particular timestamp.


We need to find a way for a script variable to show the time stamp which will select all the timestamp entries for the last 24 hours.

Anonymous
Not applicable
Author

to be simpler... Select all the tickets created between the timestamp of last 24 hours.

simospa
Partner - Specialist
Partner - Specialist

What about create a field concatenated as yyyymmddhhmmss, either for variable and your timestamps and use that?

S.