Hello
I am trying to find a solution to update Month name ( Jan, Feb, March) and year value (2025) dynamically in an update activity. The value should look like "Data from March 2025"
The Month name should be starting from next month. For example, If I run the workflow in Jan, then the month value should be FEB.
Tried using "'Data from '+Month(AddMonths(formatDate(GetDate(), '%B'), 1))+' '+Year(GetDate())" but it is giving error
XTK-170016 You are not authorized to use SQL expressions. 'formatDate' cannot be processed.
Similar to above requirement, I am also trying to add dynamic values in two fields lets say startDate and endDate.
startDate should be from 1st of next month when the workflow executes.
endDate should be last date of next month from when the workflow executes.
if the workflow executes in Feb, startDate would be 1/3/2025 and endDate would be 31/3/2025.
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @sharma_nik ,
Place an enrichment activity > advanced tab > add below script in initialization script,
//To get Next Month's First Date
var date1 = new Date();
date1.setMonth(date1.getMonth() + 1);
vars.NextMonthFirstDate = '01/'+formatDate(date1, "%2M/%4Y");
//To get Next Month's Last Date
var date2 = new Date();
date2.setMonth(date2.getMonth() + 2);
vars.twoMonthString = formatDate(date2, "%4Y-%2M")+'-01T00:00:00';
var twoMonthDate = new Date(vars.twoMonthString);
twoMonthDate.setDate(twoMonthDate.getDate() - 1);
vars.NextMonthLastDate = formatDate(twoMonthDate, "%2D/%2M/%4Y");
//Fetch Next Month
var date3 = new Date();
date3.setMonth(date3.getMonth() + 1);
vars.NextMonthString = 'Data from '+formatDate(date3, "%Bl %4Y");
logInfo("Date: "+vars.NextMonthString);
In Enrichment > add data > add the below expressions in output columns,
$(vars/@NextMonthFirstDate)
$(vars/@NextMonthLastDate)
$(vars/@NextMonthString)
Result:
Hi @sharma_nik ,
Place an enrichment activity > advanced tab > add below script in initialization script,
//To get Next Month's First Date
var date1 = new Date();
date1.setMonth(date1.getMonth() + 1);
vars.NextMonthFirstDate = '01/'+formatDate(date1, "%2M/%4Y");
//To get Next Month's Last Date
var date2 = new Date();
date2.setMonth(date2.getMonth() + 2);
vars.twoMonthString = formatDate(date2, "%4Y-%2M")+'-01T00:00:00';
var twoMonthDate = new Date(vars.twoMonthString);
twoMonthDate.setDate(twoMonthDate.getDate() - 1);
vars.NextMonthLastDate = formatDate(twoMonthDate, "%2D/%2M/%4Y");
//Fetch Next Month
var date3 = new Date();
date3.setMonth(date3.getMonth() + 1);
vars.NextMonthString = 'Data from '+formatDate(date3, "%Bl %4Y");
logInfo("Date: "+vars.NextMonthString);
In Enrichment > add data > add the below expressions in output columns,
$(vars/@NextMonthFirstDate)
$(vars/@NextMonthLastDate)
$(vars/@NextMonthString)
Result:
Thank you so much Partha for your response. It helped a lot.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies