# Datetime

**Datetime**\
Parses input string and converts into an epoch milliseconds format number. \
Input must be a string. \
@param tzmap: type dict (optional). Dictionary of timezone mappings from custom/local to standard timezones. \
@param expr: type string (optional). A custom timestamp format with UTC/local timezone.\
\
This function can be used when the datasets needs date time conversion to milliseconds or other local timezone format.

### Example 1:&#x20;

Step 1: Create an empty **datetime\_example\_1** using 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-MeW0x6gpbIiEyzgD_QR%2F-MeW1zzDqucy2PgoYV1i%2FScreen%20Shot%202021-07-13%20at%2011.05.40%20AM.png?alt=media\&token=98d73c83-c01d-42f9-9abf-417570f936ae)

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 dataset row using current year.`*\
*`##### dm function datetime is used to convert year data into milliseconds`* \
\
*`@dm:empty`* \
*`--> @dm:addrow Year_To_Epoch_MS = '2021'`* \
*`--> @dm:addrow Year_To_Epoch_MS = '2031'`* \
*`--> @dm:map attr = 'Year_To_Epoch_MS' & func = 'datetime'`*<br>

![Pipeline code added to empty pipeline created](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeW2ygiPTzFqyjHwDuF%2F-MeW3FpMxfAo98ZKA1WD%2FScreen%20Shot%202021-07-13%20at%2011.11.19%20AM.png?alt=media\&token=63d95385-df16-4f79-8c3e-2780a8c831fe)

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-MeW3RHVDW-3wQS7bx_G%2F-MeW3fKQR4FGx5vhtyeU%2FScreen%20Shot%202021-07-13%20at%2011.13.09%20AM.png?alt=media\&token=939bd472-437b-42d3-ad86-172f50bd7a33)

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-MeW3kEj5Xr1gWWO2Br0%2F-MeW446TwNs6_WkQ_btI%2FScreen%20Shot%202021-07-13%20at%2011.14.57%20AM.png?alt=media\&token=eb616e0c-5f79-45ad-bc7a-7f5e7c9e16d4)

Step 5: RDA uses the dm function datetime to convert year in string format to milliseconds format.\
&#x20; This function will be useful when the dataset contains year(s) as column values and needed to convert to milliseconds for further time calculations.

![Successful execution of pipeline using dm function 'datetime' and prints output ](https://2978683539-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhoMVYxiQlKXh6OxX98%2F-MeW4hsy2FBSmj6PjI7p%2F-MeW58GR2PXdYxuTczqz%2FScreen%20Shot%202021-07-13%20at%2011.19.37%20AM.png?alt=media\&token=12ae52c6-12fc-482f-a81f-5820651624b4)
