# Transform function reference (services)

## Field transformation function types

### Common

<table><thead><tr><th width="150">Transformation</th><th width="150">Description</th><th width="150">Input Value</th><th width="150">Transform Value</th><th width="150">Output Value</th></tr></thead><tbody><tr><td>Custom Value (True or False)</td><td>Enter a customer value as True/False (Boolean)</td><td></td><td>TRUE</td><td>TRUE</td></tr><tr><td>Custom Value (Date)</td><td>Enter a customer value as Date (DateTime)</td><td></td><td>01/13/2022</td><td>01/13/2022</td></tr><tr><td>Custom Value (Number)</td><td>Enter a customer value as Number (Integer)</td><td></td><td>123</td><td>123</td></tr><tr><td>Custom Value (Text)</td><td>Enter a customer value as Text (String)</td><td></td><td>Example</td><td>Example</td></tr><tr><td>Get Date</td><td>Return the current datetime</td><td></td><td></td><td>(Todays Date)</td></tr><tr><td>Get Unique Ref</td><td></td><td></td><td></td><td></td></tr><tr><td>Random Number</td><td>Return a random number at a specified length</td><td></td><td>5</td><td>98765</td></tr><tr><td>Run Custom Script</td><td>Run an existing <a href="/pages/oZoHN71i3KN7FMkgdP1x">custom script</a></td><td>Selected script</td><td>Script return vaulue</td><td>5</td></tr></tbody></table>

### Text (String)

<table><thead><tr><th width="150">Transformation</th><th width="150">Description</th><th width="150">Input Value</th><th width="150">Transform Value</th><th width="150">Output Value</th></tr></thead><tbody><tr><td>Contains</td><td>Check if a string contains text</td><td>Example String</td><td>"stri"</td><td>TRUE</td></tr><tr><td>Decode (URL)</td><td>Convert an encoded URL into a readable format</td><td>example%20string</td><td></td><td>Example String</td></tr><tr><td>Encode (URL)</td><td>Convert a string to a URL encoded string</td><td>Example String</td><td></td><td>example%20string</td></tr><tr><td>First Word</td><td>Get the first word from a string</td><td>Adam David John Smith</td><td></td><td>Adam</td></tr><tr><td>Get Country Code</td><td>Return the country code for a country name</td><td>Germany</td><td></td><td>12</td></tr><tr><td>Get Country Name</td><td>Return the country name for a country code</td><td>12</td><td></td><td>Germany</td></tr><tr><td>Hash</td><td>Convert a string to a SHA1 Hash</td><td>Example String</td><td></td><td>77077529426442283f684c6732a765801f938f94</td></tr><tr><td>Last Word</td><td>Get the last word from a string</td><td>Adam David John Smith</td><td></td><td>Smith</td></tr><tr><td>Lowercase</td><td>Convert a string to lowercase</td><td>Example String</td><td></td><td>example string</td></tr><tr><td>Max Length</td><td>Set the maximum number of returned characters</td><td>Example String</td><td>10</td><td>Example St</td></tr><tr><td>Middle Words</td><td>Get the middle word(s) from a string</td><td>Adam David John Smith</td><td></td><td>David John</td></tr><tr><td>Pad</td><td>Add characters before,around,after a string</td><td>Example String</td><td>Both, 18, X</td><td>XXExample StringXX</td></tr><tr><td>Prefix</td><td>Add a string to the beginning</td><td>Example String</td><td>TEST</td><td>TESTExample String</td></tr><tr><td>Propercase</td><td>Uppercase the first letter in each sentence</td><td>EXAMPLE STRING</td><td></td><td>Example string</td></tr><tr><td>Remove</td><td>Remove a string</td><td>Example String</td><td>ample</td><td>Ex String</td></tr><tr><td>Clean string</td><td>(i) Remove or replace special characters in a string</td><td>$_Example String!</td><td>replace = X</td><td>X_ExampleXStringX</td></tr><tr><td></td><td>(ii) Remove all non-alphanumeric characters in a string</td><td>$_Example String!</td><td>alphanumeric_only = true</td><td>ExampleString</td></tr><tr><td></td><td>(iii) Replace all non-alphanumeric characters in a string</td><td>$_Example String!</td><td>alphanumeric_only = true<br>replace = X</td><td>XXExampleXStringX</td></tr><tr><td>Replace</td><td>Replace any characters with another</td><td>Example String</td><td>e, X</td><td>XxamplX String</td></tr><tr><td>Substring (After)</td><td>Return characters after a value</td><td>Example String</td><td>pl, 5</td><td>e Str</td></tr><tr><td>Substring (Before)</td><td>Return characters before a value</td><td>Example String</td><td>pl, 5</td><td>Exam</td></tr><tr><td>Substring (Between)</td><td>Return characters between a two values</td><td>Example String</td><td>pl, g</td><td>e Strin</td></tr><tr><td>Substring (Range)</td><td>Return characters within a range</td><td>Example String</td><td>"3 , 7</td><td>mpl</td></tr><tr><td></td><td>(i) Using negative values allows you to return the end of a string</td><td>Example String2</td><td>"-1, -4</td><td>ing2</td></tr><tr><td>Suffix</td><td>Add a string to the end</td><td>Example String</td><td>Test</td><td>Example StringTest</td></tr><tr><td>Trim</td><td>Remove any characters around a string</td><td>xExample Stringxx</td><td>Both, x</td><td>Example String</td></tr><tr><td>Uppercase</td><td>Convert a string to uppercase</td><td>Example String</td><td></td><td>EXAMPLE STRING</td></tr></tbody></table>

### Number (Integer (123) / Float (123.456))

<table><thead><tr><th width="150">Transformation</th><th width="150">Description</th><th width="150"></th><th width="150">Transform Value</th><th width="150">Output Value</th></tr></thead><tbody><tr><td>Calculate matching key</td><td>Perform a simple calculation (+ - / *)</td><td>123</td><td>"/ , 5</td><td>24.6</td></tr><tr><td>Ceiling</td><td>Round up to the nearest whole number</td><td>24.4</td><td></td><td>25</td></tr><tr><td>Convert Weight</td><td>Convert a weight (mg, g, kg, lb, oz)</td><td>25</td><td>kg, g</td><td>25000</td></tr><tr><td>Floor</td><td>Round down to the nearest whole number</td><td>24.6</td><td></td><td>24</td></tr><tr><td>Reverse Sign</td><td>Convert a negative number to a positive number or vis versa</td><td>24.6</td><td></td><td>-24.6</td></tr><tr><td>Round</td><td>Round to specified number of decimal places</td><td>12.34567</td><td>2</td><td>12.34</td></tr><tr><td>To Negative</td><td>Return a negative value</td><td>-24</td><td></td><td>-24</td></tr><tr><td>To Positive</td><td>Return a positive value</td><td>-24</td><td></td><td>24</td></tr></tbody></table>

### Boolean (True/False)

<table><thead><tr><th width="150">Transformation</th><th width="150">Description</th><th width="150">Input Value</th><th width="150">Transform Value</th><th width="150">Output Value</th></tr></thead><tbody><tr><td>Reverse</td><td>Convert a negative to a positive or vis versa</td><td>TRUE</td><td></td><td>FALSE</td></tr></tbody></table>

### Date / DateTime

<table><thead><tr><th width="150">Transformation</th><th width="150">Description</th><th width="150">Input Value</th><th width="150">Transform Value</th><th width="150">Output Value</th></tr></thead><tbody><tr><td>Adjust Date</td><td>Add or Subtract units (Seconds, Minutes, Hours, Days, Weeks, Months, Years)</td><td>4/Jul/2022</td><td>+ , 100, Days</td><td>12/Oct/2022</td></tr><tr><td>Convert Date</td><td>Convert a date to another timezone / format</td><td>4/Oct/2022 12:00</td><td>gmt > hk, dd-MMMM-yy</td><td>"04-October-22 20:00</td></tr><tr><td>Convert to String</td><td>Convert a date to a string</td><td>4/Oct/2022 12:00</td><td>y/m/d</td><td>2022/10/4</td></tr><tr><td>Date Comparison</td><td>Check if a date is before/equal/after</td><td>4/Jul/2022</td><td>Before, 10/Jul/2022</td><td>TRUE</td></tr><tr><td>Date Diff</td><td>Return the difference between 2 dates</td><td>4/Jul/2022</td><td>15/Jul/2022, days</td><td>14</td></tr></tbody></table>

c


---

# 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://doc.wearepatchworks.com/product-documentation/patchworks-services/working-with-services/field-mappings-and-transformations-services/field-transformations-services/transform-function-reference-services.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.
