# Ts\_To\_Datetimestr

**Ts\_To\_Datetimestr**\
Processes input number with specified '**unit**' (s, ms, ns, excel\_date) and converts the value to **datetime** string specified by '**format**',  default is ISO format. \
Input must be a float or int. \
@param '**unit' (**&#x54;ype string), must be s,ms,ns,excel\_date, default is '**ms**' \
@param '**format' (**&#x54;ype string), default is None (ISO format)\
\
This function is useful in case users want to convert to proper date-time strings.

### Example 1:&#x20;

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

![Empty pipeline](/files/-MeSxiM_Zn80c5_ROp8Z)

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 time in milliseconds.`*\
*`##### dm function ts_to_datetimestr is used to convert string data into proper`* \
*`##### date time string using ISO format (default). This function takes an additional`* \
*`##### parameter unit using 'ms', 's'.`* \
\
*`@dm:empty`* \
*`--> @dm:addrow Time_in_Milliseconds = '1626147743837'`*\
*`--> @dm:map to = 'Time_in_String' & from = 'Time_in_Milliseconds' & func = 'ts_to_datetimestr' & unit = 'ms'`* \
*`--> *dm:filter * get Time_in_String`*<br>

![Pipeline code added to empty pipeline created](/files/-MeT-MSuxfmvgmqCDrGS)

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.](/files/-MeT-wiBNax2-CGbVtvC)

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](/files/-MeT0MJTW-_gcw7fGSYh)

Step 5: RDA uses the dm function **ts\_to\_datetimestr** to convert milliseconds into readable string format using ISO format as shown below.\
\
&#x20;This function will be useful when the dataset contains timestamps in ms, s, excel\_date that need to be converted to string format for reporting purposes.

![Successful execution of pipeline using dm function 'ts\_to\_datetimestr' and prints output in string format](/files/-MeT35G8ZadK-UeEksqO)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cloudfabrix.io/rda/rda-userguide/rda-aiops-studio/examples-jupyter/data-mapping-cfxdm-dm-functions/ts_to_datetimestr.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
