# If (DateTime)

| **Name**    | ***If (DateTime)***                                                                                                                                                                                                                                                                 |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Syntax      | If (Boolean condition, DateTime thenValue, DateTime elseValue)                                                                                                                                                                                                                      |
| Purpose     | To evaluate a given condition and if true, return result of thenValue. Otherwise, to return the result of elseValue.                                                                                                                                                                |
| Description | Returns the value of ‘Then’ expression or ‘Else’ expression depending on the value of condition.                                                                                                                                                                                    |
| Return Type | DateTime                                                                                                                                                                                                                                                                            |
| Parameters  | <p>Condition \[System.Boolean]</p><p>thenValue \[System.DateTime] – This Parameter’s value is returned if the result of ‘condition’ parameter is true.</p><p>elseValue \[System.DateTime] - This Parameter’s value is returned if the result of ‘condition’ parameter is false.</p> |

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/yceiJPmJ09AUAn7rEK9M/0.png)

### **Example**

We have a *Customers* dataset which we will use to evaluate and transform the *ShipDate* field.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/Iw7w9V54UCG1FGdSx6ry/1.png)

In this example we will use the *Expression* object to define the condition, and a *Variables* object to define *thenValue* and *elseValue*.

Where,

Condition: *ShipDate* = “1”

*thenValue* = 1/2/2022

*elseValue* ­ = 5/7/2023

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/Y57X6BfmcjxXpY6KQeBp/2.png)

In the output, you can see that DateTime values, 1/2/2022 and 5/7/2023, have been returned depending on whether the *ShipDate* field condition was met.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/hasqIl70MwrgmynZkaPM/3.png)
