# Minutes\_Between

**Minutes\_between**

The number of minutes between two date-time strings. If only one is specified, it compares the difference between it and the current timestamp.

### Example 1:&#x20;

Step 1: Create an empty **minutes\_between\_example\_1** using AIOps studio as shown in the below screenshot. 

![Empty pipeline ](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeNyayP5H0K3ef3owVD%2F-MeO79SJvhcHSLnf6m-8%2FScreen%20Shot%202021-07-11%20at%2010.11.21%20PM.png?alt=media\&token=e07fcb05-f7da-48f8-92fb-01a07980bb60)

Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:

You can copy the below code into your pipeline and execute that in your environment.\
\
\&#xNAN;*`##### This pipeline creates a simple time fields time1 and time2 with two distinctive`*\
*`##### values as a dataset.`* \
*`##### Pipeline uses RDA dm function minutes_between to calculate minutes between two`*\
*`##### timestamps and prints the value. In addition, RDA dm function ts_to_datetimestr`*\
*`##### is used to convert the the time difference into string (other units are ms,ns,`* \
*`##### excel_date)`*\
\
\
*`@dm:empty`* \
*`--> @dm:addrow time1 = 1623193065990 & time2 = 1623193085990`*\
*`--> @dm:map to = 'Change_In_Minutes' & from = 'time1,time2' & func = 'minutes_between'`*\
*`--> @dm:map attr = 'Change_In_Minutes' & func = 'ts_to_datetimestr' & unit = 's'`*<br>

![Pipeline code added to empty pipeline created](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeOAS0CZ3ONKB8Jaupu%2F-MeOAnkafMsMosQAR_ZQ%2FScreen%20Shot%202021-07-11%20at%2010.27.08%20PM.png?alt=media\&token=cc9e6162-d268-439d-be64-ca9fe3a947b9)

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![Pipeline code is verified using 'Verify' button as shown above.](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeOAsZyORNxbEwJnEfo%2F-MeOB_70IezC4P0XSJB3%2FScreen%20Shot%202021-07-11%20at%2010.30.43%20PM.png?alt=media\&token=a4ca8fa1-2970-4171-8c3b-ff26b6b5889c)

Step 4:  Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Successful execution of pipeline without any errors](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeOBftYRSx7rLQ58Om5%2F-MeOC1q3g-IYkNdvpGS2%2FScreen%20Shot%202021-07-11%20at%2010.32.43%20PM.png?alt=media\&token=5a4fe3c6-cde7-49f3-ac44-e386e5e8e2b3)

Step 5: RDA uses the dm function minutes\_between  to calculate the difference between two timestamps and presents the output as shown below screenshot. \
Note: In addition to the above dm function, the pipeline also uses ts\_to\_datetimestr to convert the timestamp value to a string.

![Successful execution of pipeline using dm function 'minutes\_between' between two times and prints output](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeOCmB3BG_4jxaRqRps%2F-MeODJjfKRHrnHluaAJr%2FScreen%20Shot%202021-07-11%20at%2010.38.21%20PM.png?alt=media\&token=d7845b13-ac03-4343-9a6d-a006f7dd615b)
