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

Solved!
DvMg
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 Solution
Mattsco
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

View solution in original post

0 Kudos
1 Reply
Mattsco
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

?
Labels (1)
A banner prompting to get Dataiku