Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am trying to generate a UNIX timestamp with the now() function that needs to be used in a API call. I need to generate the UNIX timestamp at the moment of calling the API endpoint.
Therefore I use: let vtimestamp = Floor(now()-MakeDate(1970,1,1))*86400;
However, it is not working as expected. At this moment, it returns for example '1718409600', while the current timestamp is 1718458763. Even when I refresh the page and run the script again, it still returns an old value.
Is there some reason why I do not get the current timestamp?
Thanks in advance.
Kind regards, Sterre
@SterreKapteijns wrote:
Of course I run the script, but then the function will still not return the current timestamp.
Furthermore, I need the timestamp, not the date and today(1) will return the date.
Even more confused now. If you need the timestamp, why are you floor()ing?
Did you perchance intend to floor() outside of the multiplication by seconds?
Floor((now()-MakeDate(1970,1,1))*86400)
Hi, the default returns the last finished data load, try with Now(1): https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/Scripting/DateAnd...
Hi,
I have tried using Now(1), but I still get an 'old' timestamp.
Kind regards,
Sterre
I am a tad confused. Why would the timestamp created during the reload script change when you open or refresh the app? Opening or refreshing the app does not run the reload script...
If that's what you're after, you can use the variable editor to create an on-the-fly variable rather than creating it in your script.
As the linked help page states:
now( 1) |
|
I need the variable in the API call, therefore creating the on-the-fly variable would no be possible right?
Yeah I have read the documentation, however it does not work as described. The function is called in the load script, however it does not return the time the function is called during the data load.
If you're making the API call from script, then you would indeed want to use a script variable, but - that variable doesn't change when you open the app, only when the script is run.
I'd also suggest using today(1) rather than Now(1), since you seem to be floor()ing away the time aspect anyway, but that shouldn't impact the result, just cleaner to read.
Of course I run the script, but then the function will still not return the current timestamp.
Furthermore, I need the timestamp, not the date and today(1) will return the date.
@SterreKapteijns wrote:
Of course I run the script, but then the function will still not return the current timestamp.
Furthermore, I need the timestamp, not the date and today(1) will return the date.
Even more confused now. If you need the timestamp, why are you floor()ing?
Did you perchance intend to floor() outside of the multiplication by seconds?
Floor((now()-MakeDate(1970,1,1))*86400)