Community Conundrum 25: Feature Visualization is now live! Read More

How can create a variable with the name of the month?

Level 1
How can create a variable with the name of the month?
Hi All

I want to create a variable with the name of the actual month for it will be the subject of my email reporter.

How can do it?

Thanks
0 Kudos
1 Reply
Dataiker
Dataiker
Hi DvMg,

In a python recipe you can use this code to set the project variable at the name of current month. You'll have to rerun it every month with a scenario.


import dataiku
from datetime import datetime

projectKey = dataiku.get_custom_variables()["projectKey"]
c = dataiku.api_client()
p = c.get_project(projectKey)
v = p.get_variables()
v["standard"]["current_month"] = datetime.now().strftime('%B')
p.set_variables(v)
Mattsco
0 Kudos
Labels (1)