Question: I want to add greater then and lessthen condition in below example. is it possible?
[![enter image description here](https://i.stack.imgur.com/rSzsf.png)](https://i.stack.imgur.com/rSzsf.png)

Answer: 
"you want to use diff function to take the time differences between a VECTOR elements, only in the units specified"

pls try below code : (by int\_diff function)

```
> VECTOR = c(ymd_hms("2016-05-10 16:17:03"),
+            ymd_hms("2016-05-10 16:17:04"),
+            ymd_hms("2016-05-10 17:19:33"),
+            ymd_hms("2016-05-10 19:55:03")
+ )
> as.numeric(int_diff(VECTOR))
[1]    1 3749 9330
> round(as.numeric(int_diff(VECTOR))/3600,2)
[1] 0.00 1.04 2.59

```

see, whatever the time interval min unit is seconds or not, it is always scaled by seconds as below.

```
> VECTOR = c(ymd_hms("2016-05-10 16:17:03"),
+            #ymd_hms("2016-05-10 16:17:04"),
+            ymd_hms("2016-05-10 17:19:33"),
+            ymd_hms("2016-05-10 19:55:03")
+ )
> as.numeric(int_diff(VECTOR))
[1] 3750 9330
> round(as.numeric(int_diff(VECTOR))/3600,2)
[1] 1.04 2.59

```
or you can use this way:

```
library(lubridate)
x=ymd_hms("2016-05-09 16:17:03") 
y=ymd_hms("2016-05-19 16:17:04")
diffs=as.duration(x-y);
IntervalsInHours=abs(diffs)/dhours(1);IntervalsInHours

```