how to create custom date format in scenario variables

obireddy
obireddy Registered Posts: 13 ✭✭

Hi Team,

I want to create scenario variable as custom date format a yyyy-mm-dd or dd-mm-yyyy hh:mm:ss from now() function where it has T & Z characters in date time format.

could you please help on it how to create formals in defining scenario variable in scenario steps?

Thanks in advance.


Operating system used: windows

Tagged:

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,049 Neuron
    edited July 17
    import datetime
    from dataiku.scenario import Scenario
    scenario = Scenario()
    
    my_date=datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
    scenario.set_scenario_variables(my_date=my_date)
    print("****** " + my_date)

    [variables={"my_date": "2024-05-08T08:38:23Z"}]
    [2024/05/08-08:38:23.047] [Exec-98379] [INFO] [process]  - ****** 2024-05-08T08:38:23Z

Setup Info
    Tags
      Help me…