0

Hi Guys!

I am having an issue, while comparing MySQL date time with format using javascript,

for an example: 2016-01-25 01:22:00

i load it and trying to compare it with in the JavaScript scope, but its not working, am using "Modified Java Script Value" with in the Pentaho Data Integration aka kettle

Its not working and showing errors, that invalid date, can anyone time me what is the correct format with in JavaScript and what format is needed when comparing date time in the JavaScript scope? Do i need to change the format?

shzyincu
  • 409
  • 4
  • 21

1 Answers1

0

Okay i found that you just need to replace "-" with "/" :)

Example:

NOTE: below code is from Modified Java Script Value with in Pentaho Data Integration.

Should be forward slashes, otherwise its not being accepted by the DATE constructor, says invalid date :(, i was trying to compare hard coded dates with the MySQL time stamp.

var d1 = new Date("2015/08/17 21:31:06");

var d2 = new Date("2015/08/17 21:31:07");

Alert(d1.getTime() < d2.getTime());

Interesting thing i have found is that, it can be compared with a time stamp from MySQL using HYPHENS between year-month-date, but to achieve that you have to first use select step in kettle and change the type of the field to DATE and use the format like "yyyy-MM-dd HH:mm:ss"

You can use your own formats, i was querying MAGENTO table, so i used this format

Still if there is anything more professional in terms of accomplishing this task, do share...

shzyincu
  • 409
  • 4
  • 21