How to format dates with Pentaho Spoon

Viewed 130

How do I convert the string 03-MAR-2021 to the string 20210303 with Javascript in Pentaho Spoon

start_date="03-MAR-21";

var new_startDate= new Date(start_date);

var date= moment(new_startDate).format('yyyyMMdd');
2 Answers

See common date formats

start_date="03-MAR-2021";

var date= str2date(start_date, "dd-MMM-yyyy");

var formatedDateString = date2str(date, "yyyyMMdd");

I get the date in a string like '03-Mar-2021' but I need to convert to string '20210303' (YYYYMMDD) I can make in JScript or directly on Query. But I have problems when I try to

 Jscrip Error from ETL .... See screenshot! .

Related