# Date and Timestamp

### Examples:&#x20;

&#x20;[incidents.csv](https://macaw-amer.s3.amazonaws.com/rda/data/incidents.csv) -- This file contains a set of tickets/incident details

### ts\_to\_datetimestr  -  Parses input timestamp in milliseconds and converts human readable string

Step 1: Create an empty pipeine datetime\_example AIOps studio as shown in the below screenshot

![Empty pipeline creation using AIOps Studio](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MbhH1vHeIw2HZAZNS7f%2F-MbhHea5H2ZyT6jpSW0O%2FScreen%20Shot%202021-06-08%20at%201.22.35%20PM.png?alt=media\&token=ed21c2f5-8270-4fa4-a023-d0b5a06116c6)

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 set of records (ipaddress, timestampin milliseconds,`* \
*`##### id) using AIOps studio.`*\
\
*`##### Using RDA functionality *dm:filter renamed two column names`*\
*`##### ipaddresss to IP_Address, time to Alert_Time`*\
*`##### After renaming is completed, dm:function 'ts_to_datetimestr' is used`*\
*`####  to convert timestamp into human readable format.`*\
&#x20;\
*`@dm:empty`* \
*`--> @dm:addrow ipaddress = '10.10.1.1' & time = '1623193065990' & id = 'a1'`*\
*`--> @dm:addrow ipaddress = '10.10.1.2' & time = '1623193065990' & id = 'a2'`*\
*`--> @dm:addrow ipaddress = '10.10.1.3' & time = '1623193065990' & id = 'a3'`*\
*`--> @dm:addrow ipaddress = '10.10.1.4' & time = '1623193065990' & id = 'a4'`*\
*`--> *dm:filter * get id,ipaddress as 'IP_Address',time as 'Alert_time'`*\
*`--> @dm:map attr = 'Alert_time' & func = 'ts_to_datetimestr' & unit = 'ms'`*

**Note:  ts\_to\_datetimestr parameter unit (from the above) supports "ms, ns,s, excel\_date" formats.**\
\
Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![Pipeline code and verification of syntax for dm:func 'ts\_to\_datetimestr'](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MbhoLqnAFDaA9xDVZx6%2F-MbhoOEc6KSZicteEYwA%2FScreen%20Shot%202021-06-08%20at%203.49.45%20PM.png?alt=media\&token=d97edbd2-0a6c-4322-8911-5fb57b2456aa)

Step 4:  Click execute button and execute the pipeline. Once the pipeline is executed, verify data from Alert\_time column that shows human readable time string (as shown in the below screen shot).

![Execute pipeline by clicking 'Execute' button. Above shows sucessful execution](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-Mbhorx42WSu-lD00E4o%2F-MbhpJxhUM0A1cUTlTIC%2FScreen%20Shot%202021-06-08%20at%203.54.02%20PM.png?alt=media\&token=5a3df27a-b8b0-4cef-8d43-e1d6adb28d4a)

Step 5:  Verify the data (as shown in the below screenshot)

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-Mbhpl7nsrw8yA-rMccb%2F-Mbhr5scz0G9EafY_xCK%2FScreen%20Shot%202021-06-08%20at%204.01.34%20PM.png?alt=media\&token=3e8aaf69-942a-484c-8c1a-836af1fcd1e4)

### datetime  -  **Convert Human readable Date & Timestamp to Milliseconds**

Step 1: Create an empty pipeine datetime\_to\_milliseconds\_example

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MbhzKNEf1yK41STst6c%2F-MbhzM0jx2l8zKlirPT9%2FScreen%20Shot%202021-06-08%20at%204.37.44%20PM.png?alt=media\&token=9610267f-cd4f-47dd-a794-cf8413b734c4)

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 set of records (ipaddress, timestampin milliseconds,id)`* \
*`##### using AIOps studio.`*\
\
*`##### Using RDA functionality *dm:filter renamed two column names`*\
*`##### ipaddress to IP_Address, timestamp to Timestamp_in_milliseconds`*\
*`##### After renaming is completed, dm:function 'datetime' is used`*\
*`####  to convert timestamp in string format into timestamp in milliseconds`*\
&#x20;\
*`@dm:empty`* \
*`--> @dm:addrow ipaddress = '10.10.1.1' & timestamp = '2021-01-15 03:00:00' & id = 'a1'`*\
*`--> @dm:addrow ipaddress = '10.10.1.2' & timestamp = '2021-01-15 04:00:00' & id = 'a2'`*\
*`--> @dm:addrow ipaddress = '10.10.1.3' & timestamp = '2021-01-15 05:00:00' & id = 'a3'`*\
*`--> @dm:addrow ipaddress = '10.10.1.4' & timestamp = '2021-01-15 06:00:00' & id = 'a4'`*\
*`--> *dm:filter * get id,ipaddress as 'IP_Address',timestamp as 'Timestamp_in_milliseconds'`*\
*`--> @dm:map attr = 'Timestamp_in_milliseconds' & func = 'datetime'`*<br>

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

![Pipeline code snippet validation ](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-Mbi0qDVyvHOven1nIe9%2F-Mbi1AptnUuQC_iAmkM3%2Fimage.png?alt=media\&token=2919e5ec-e38c-4cb0-acc0-9fba604677e8)

Step 4:  Click execute button and execute the pipeline. Once the pipeline is executed, verify data from Alert\_time column that shows human readable time string (as shown in the below screen shot).

![Successful execution of pipeline code](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-Mbi1Mt4yfauSWXxO_s6%2F-Mbi1tRheKPwTeNejZqj%2FScreen%20Shot%202021-06-08%20at%204.53.04%20PM.png?alt=media\&token=b555a086-21b4-44de-9d04-f31a65df92a5)

Step 5:  Verify the data (as shown in the below screenshot)

![](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-Mbi21sPeaYQl6aBrfhl%2F-Mbi2RzytRK7yCbfSHji%2FScreen%20Shot%202021-06-08%20at%204.55.49%20PM.png?alt=media\&token=e1dc3461-5455-429b-b013-ab4c0c734759)
