I'm fairly new to talend, and i'm trying to get datedifference between each row of a table. Example:
I need to create a fact table with the difference between each row, so i can know how much "ON" time the machine is having. I've tried the diffdate in tmap component, but i cannot find a way to calculate that time. Can someone with experience help me throught it?
An easier way of achieving this would be to convert the dates into milliseconds (get a Date object and call getTime()) and subtract one from the other. Then you can carry out the maths on the remainder.
For example, if the difference between the dates comes to 6543892716, then the difference is calculated below...
6543892716/1000 = 6543892.716 seconds
6543892.716/60 = 109064.8786 minutes
109064.8786/60 = 1817.747976666 hours
1817.747976666/24 = 75.73949902777 days
0.73949902777*24 = 17 hours
0.747976666666*60 = 44 mins
0.8786*60 = 52 seconds
0.716*1000 = 716 milliseconds
So that equates to 75 days, 17 hours, 44 mins, 52 seconds and 716 milliseconds
I stepped through that in a long winded fashion, you can cut corners using a modulus operation or two :-)