# 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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FdiKXvOA10Qx7cI9u7EOz%2F0.png?alt=media)

### **Example**

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FIrcRltcEG3qScpMQ8QFq%2F1.png?alt=media)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fo4Vfda6O9265Hjyxvuzp%2F2.png?alt=media)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FVyqpp3bq37z99FDluuUg%2F3.png?alt=media)
