# Seconds\_Between

The number of seconds 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 **seconds\_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-MeRI_L7bHT2ir-uQOra%2F-MeRIv3wS18C3WU-bgeU%2FScreen%20Shot%202021-07-12%20at%201.01.38%20PM.png?alt=media\&token=0e9bc542-a887-4cc0-8c12-291059c69c30)

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 seconds_between to calculate seconds 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_Seconds' & from = 'time1,time2' & func = 'seconds_between'`*\
*`--> @dm:map attr = 'Change_In_Seconds' & 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-MeRP7mE4mBruQxA4y2z%2F-MeRPSRjiZ5OghmYAoJ5%2FScreen%20Shot%202021-07-12%20at%201.30.15%20PM.png?alt=media\&token=2a554a8b-c0d4-48bd-beb8-2cc9ae7d00f6)

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-MeRPXSOAMghL4ItHZYW%2F-MeRPkrit19oBvsqPgWe%2FScreen%20Shot%202021-07-12%20at%201.31.33%20PM.png?alt=media\&token=19aa9d02-a75b-4206-bcce-d3096bb671b5)

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-MeRPpdFRCGCaltDfMx_%2F-MeRQLmthYRd9G2VZY6j%2FScreen%20Shot%202021-07-12%20at%201.34.10%20PM.png?alt=media\&token=80ffa34b-6a8b-4ede-bfc1-a88f2c9db795)

Step 5: RDA uses the dm function seconds\_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 'seconds\_between' between two times and prints output](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeRQQHAf37kG47eeAqR%2F-MeRQkT-QbGVYFOnrNG2%2FScreen%20Shot%202021-07-12%20at%201.35.56%20PM.png?alt=media\&token=8f4b3462-c40e-4d5f-843b-35dbf5217497)
