Alteryx custom column code into knime column expression node.

I have one code which create custom column based on current date calculate last day of last month,

here is my Alteryx code, how can I write this code into column expression node.

DateTimeAdd(
DateTimeTrim(DateTimeToday(),‘FirstOfMonth’)
,-1
,‘day’)

and second custom column code is for duration
DateTimeDiff([LastOfPreviousMonth],[Scanning date],“month”)

Help me with this custom column migrate into column expression node in knime

Hi @vinay,

calculating the date of the last day of last month can be achieved with:

tday=today()
firstOfMonth = date(getYear(tday),getMonthOfYear(tday) ,1 )  // first of the month
LastOfPreviousMonth=plusTemporal(firstOfMonth , periodOfDays(-1))

LastOfPreviousMonth

To get the date difference between your column “Scanning Date” and the LastOfPreviousMonth calculated in the above Column Expressions, I would suggest following the Column Expressions node with a Date&Time Difference node

3 Likes

Thank You so much this is very helpful

1 Like

You’re welcome @Vinay1995 , and thank you for marking the solution :slightly_smiling_face:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.