DVF date functions
Learn about the date functions used in a data validation.
Use date functions in Data Validation Functions (DVF) to validate attributes that have a date format of YYYY-MM-DD.
Function | Description | Sample |
---|---|---|
range | The validation function checks that the attribute value is between the two static dates. If the validation is met, then the appropriate validation message is displayed. |
|
equals | The validation function checks that the attribute value matches the given static date or another date attribute value exactly. If the validation is met, then the appropriate validation message is displayed. This function supports the NOT conditional operator. |
|
gt | The validation function checks that the attribute value is greater than the given static date or another date attribute value. If the validation is met, then the appropriate validation message is displayed. This function supports the NOT conditional operator. |
|
gte | The validation function checks that the attribute value is greater than or equal to the given static date or another date attribute value. If the validation is met then the appropriate validation message is displayed. This function supports the NOT conditional operator. |
|
lt | The validation function checks that the attribute value is lesser than the given static date or another date attribute value. If the validation is met then the appropriate validation message is displayed. This function supports the NOT conditional operator. |
|
lte | The validation function checks that the attribute value is lesser than or equal to the given static date or another date attribute value. If the validation is met, then the appropriate validation message is displayed. This function supports the NOT conditional operator. |
|
exists | The validation function checks that the given attribute value exists. If the validation is met, then the appropriate validation message is displayed. |
|
missing | The validation function checks that the given attribute value is missing. If the validation is met, then the appropriate validation message is displayed. |
|
relative date comparisions | The validation function checks that the attribute value is within a relative date, in days, to the current date. For example, check if the DOB value is less than 1 day from the current date when validated. For more information, see section Use DVF expressions to compare relative dates During validation, the current date is compared against relative dates in the Coordinated Universal Time (UTC) timezone. See the section below for more details. Note: For DVFs created with the Validate event field set to Create & Update profile or Update profile we recommend you only use the gte function. For DVFs created with the Validate event field set to Create profile, we recommend you only use the |
|
Use DVF expressions to compare relative dates
DVF expressions allow for dynamic comparisons of dates relative to the current date. Let's explore how to use DVF expressions with relative date comparisons using the following examples::
- The Manufacturing date should be less than 2 years from the current date
- The Supply date must be three months after the current date
- The Sales date is equal to the current date
- The Promotion date is 10 days from the current date
The following table illustrates how these conditions are expressed using DVF expressions:
Comparator | Example DVF expression | Description |
---|---|---|
lt (less than) | lt(attributes.ManufacturingDate.value, -P2Y) | The Manufacturing date is less than 2 years before the current date. -P2Y represents a period of 2 years in the past using the ISO-8601 format. |
lte (less than or equal to) | lte(attributes.ManufacturingDate.value, -P2Y) | The Manufacturing date is less than or equals to 2 years before the current date. -P2Y represents a period of 2 years in the past, using the ISO-8601 format. |
equals | equals(attributes.PromotionDate.value, P10D) | The Promotion date is exactly 10 days from the current date. P10D represents a period of 10 days from today in the ISO-8601 format. |
equals | equals(attributes.SaleDate.value, P0D) | The Sale date is equal to the current date. The P0D here denotes the current date in the ISO-8601 format. |
gt (greater than) | gt(attributes.SupplyDate.value, P3M) | The Supply date is more than three months from the current date. P3M represents a period of 3 months in the future in the ISO-8601 format. |
gte (greater than equals) | gte(attributes.SupplyDate.value, P3M) | The Supply date is at least three months from today. |
Expression | Meaning |
---|---|
P32D | 32 days (in the future) from today |
P15M | 15 months (in the future) from today |
P5Y | 5 years (in the future) from today |
-P3Y | 3 years ago |
-P10M | 10 months ago |
-P28D | 28 days ago |
Relative dates comparison to UTC timezone
The date and timestamp fields are compared against relative dates in the Coordinated Universal Time (UTC) timezone.
When entering a date, there may be an anomaly when it compares the user's date (who is in a different timezone) to the UTC timezone. Here's an example.
Timezone A is 8 hours ahead the UTC timezone. A user in timezone A enters the current date as the 30th September at 4am. However, as per UTC, the current date is 29th of September at 8pm. During validation, the system infers the current date as 29th (as per the UTC timezone) and throws an error.
Timestamps, however, do not have such anomalies since the Timestamp
field type is stored and compared in UTC only. System dates for entities, such as Start Date and End Date, are stored as timestamps and hence, will not face such anomalies.