# Thread: Difference/substract Timestamp

1. Junior Member
Join Date
Nov 2015
Posts
15

## Difference/substract Timestamp

Hi all,

I'm currently getting the result of the difference of two timestamps. The problem is with the result timestamp. Here is an example being res1=(A-B) from http://wiki.pentaho.com/display/EAI/Calculator:

date1 date2 res1
2016/12/12 13:41:17.324116000 2016/12/12 13:41:17.432933000 1970/01/01 01:00:00.000000108
2016/12/12 13:41:17.450360000 2016/12/12 13:41:17.468388000 1970/01/01 01:00:00.000000018
2016/12/12 13:41:21.634654000 2016/12/12 13:41:17.468388000 1970/01/01 01:00:00.000000645

The result shouldn't be 1970/01/01 01:00:00.108817000 for the file numer 1?

Thanx so much.

2. Senior Member
Join Date
Jun 2012
Posts
5,534
Actually, the difference between 2 Timestamp values isn't a TimeStamp, but a certain amount of nanoseconds.
You shouldn't interpret that amount as a localized Timestamp.

3. Junior Member
Join Date
Nov 2015
Posts
15
Hi! thx for the answer

I'm doing something like this in a step named like "javascript modified":

var diff_hours = dateDiff(timestampInicio, timestampFin,"hh");
var diff_minutes = dateDiff(timestampInicio,timestampFin,"mi");
var diff_seconds = dateDiff(timestampInicio,timestampFin,"ss");

var hourstomin = diff_hours*60;
var secondstomin = diff_seconds/60;

var ResultMin = hourstomin + secondstomin + diff_minutes;

Anyways, do pentaho have any kind of step to convert the nanoseconds between the difference with 2 timestamps?

4. Senior Member
Join Date
Jun 2012
Posts
5,534
Originally Posted by Alsrroum
do pentaho have any kind of step to convert the nanoseconds
Convert to what?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•