2

I have an input excel sheet which has a field "fail_date". I want to change the format to dd.MM.yyyy HH:mm:ss. I am doing this in javascript shown below.

var temp = fail_date.getDate();
str2date(temp,"dd.MM.yyyy HH:mm:ss");

But I get the below error when i run

2015/05/07 17:48:01 - Modified Java Script Value 2 2 2.0 - ERROR (version 4.4.0-stable, build 17588 from 2012-11-21 16.02.21 by buildguy) : Could not apply the given format dd.MM.yyyy on the string for Thu Jan 01 11:05:50 IST 1970 : Format.parseObject(String) failed (script#5)

script#5 points to str2date(temp,"dd.MM.yyyy HH:mm:ss"); . Please help to solve this issue.

jacktrade
  • 3,125
  • 2
  • 36
  • 50
tester
  • 213
  • 6
  • 20
  • `getDate()` in javascript `Date` object returns the date of month `[1-31]`. Looks like you are passing an invalid date to be converted. You will have to show the value of `temp` and body of the function `str2date` for further help. – sabithpocker May 07 '15 at 12:29
  • The value present in Input excel is "1970/01/01 11:05:50.312" [data type is Date] In pentaho, this value is read in "temp" and value is "Thu Jan 01 11:05:50 IST 1970" . In pentaho, str2date is an inbuilt function. USAGE : str2date("01.12.2006 23:23:01","dd.MM.yyyy HH:mm:ss"). – tester May 07 '15 at 12:43

1 Answers1

0

the variable temp is setted as date type object, but when you apply the str2date function, this function expects to be temp as string.

So this is how your code should be:

var temp = fail_date.getDate();
temp = date2str(temp,"dd.MM.yyyy HH:mm:ss");

remember now temp is a string type

jacktrade
  • 3,125
  • 2
  • 36
  • 50
  • Also, now, the variable temp is set as string. var temp = fail_date.getString(); temp = str2date(temp,"dd.MM.yyyy HH:mm:ss"); But I get the below error Could not apply the given format dd.MM.yyyy HH:mm:ss on the string for 2015/03/02 04:00:31.000 : Format.parseObject(String) – tester May 20 '15 at 14:13