Hello, is there a way to get the execution date of...
# ask-the-community
a
Hello, is there a way to get the execution date of a task or workflow scheduled to run at intervals. The idea is to dynamically pass in the execution date as parameter in the task/workflow. Also, if there is need to rerun a task from past runs, the specific execution date for that run will be passed and not the current date.
f
Does this maybe help you?
Copy code
@workflow
def date_formatter_wf(kickoff_time: datetime):
    formatted_kickoff_time = format_date(run_date=kickoff_time)
    print(formatted_kickoff_time)
Copy code
cron_lp = LaunchPlan.get_or_create(
    name="my_cron_scheduled_lp",
    workflow=date_formatter_wf,
    schedule=CronSchedule(
        # Note that the ``kickoff_time_input_arg`` matches the workflow input we defined above: kickoff_time
        # But in case you are using the AWS scheme of schedules and not using the native scheduler then switch over the schedule parameter with cron_expression
        schedule="*/1 * * * *",  # Following schedule runs every min
        kickoff_time_input_arg="kickoff_time",
    ),
)
k
a
Thanks @Fabio Grätz @Ketan (kumare3)
152 Views