Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
johnan
Creator III
Creator III

Get yesterday date Let ExecutionTime = date(now()-1);

Hi all.

How can i get yesterdays date in my SQL (AS400)

In my app i have:

Let ExecutionTime = date(now()-1);
But i'ts doesent work, i have to load the app 2 times to get yesterdays date.

Mayby a Macro can work? Before loading?

6 Replies
Not applicable

Now function will give you Timestamp also, so make sure you are picking up the date part of it.

stephencredmond
Luminary Alumni
Luminary Alumni

Hi,

Use the Today() function instead of Now(). Today() doesn't have any time portion so there should be no confusion.

Regards,

Stephen

johnan
Creator III
Creator III
Author

Hi all.

I've tried but i think we have to initiate yesterdays day before i loading the SQL script?

First in my script:

Let ExecutionTime = date(today()-1)

Then my SQL:
Select bla, bla from table where date = '$(ExecutionTime )';
When the sript reload tomorrow i have today's date in variable ExecutionTimeSad

Anonymous
Not applicable

I apologize in advance..I might sound like an idiot here but when you say that tomorrow it will have today's date, isn't that correct? Or it it one off all the time?

In that case I would suggest checking the system clock/calendar settings. Sounds like you would get the "correct" result with today()-2 but there has to be an underlying reason for why it picks the wrong date for you from the get go.

johnan
Creator III
Creator III
Author

Hi,

It's the point to show yesterdays numbers in my report when you viewing the report today. I'll have to reload the qv evrey morning at six.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I suggest always using an explicit parameter like today(1) and now(1). The defaults are different between the two functions, and the behavior is different between script and chart usage (and release 7 to releae 8 as well).

Try today(1)-1;

-Rob