Hi! I am setting up a workflow where I need to dynamically set a property of an HTML request node which takes timestamps as a value. I was able to use for example {{new Date().toISOString()}} to set the current date time, but I need to reference somehow the timestamp of the previous successful execution in order to always fetch new data.
A possible approach would be to store the past execution time along with the workflow data at the end of your workflow using the Function node.
The downside to this approach is that this data is only available in production executions and not when testing a workflow through the UI. If you need this to also work for manual executions through the UI you’d need to store the time outside of n8n, for example in an external database.
The lastExecution field would be updated whenever the workflow executes.
Here’s a quick example putting this all together and doing nothing except reading and writing this data:
Example Workflow
You can copy these example Function nodes into any of your workflows as needed, no environment variables would be needed.
The only thing to keep in mind is that they won’t return any data when manually running your workflow. So when testing this you’d need to trigger a production execution and then look up the data via the executions list: