Articles in this section

How to transform a date and time in text format into a date object using DateValue()

This article explains what the DateValue() function is and provides examples of how it can be used with the binding syntax in smart templates.  

  Prerequisites

  • Library and at least one Dynamics modules enabled.
  • Templafy Desktop and Office VSTO add-in installed on the PC.
  • Space owner access to the Templafy tenant.

What is the DateValue() function? 

DateValue() is a function used for converting plain text dates into a date object for use in other date functions such as FormatDateTime(). This function is often used for taking dates from external systems such as Salesforce and making them usable with date functions in Templafy.

DateValue() logic

Syntax {{DateValue(DateTime,Format,Region)}}
Input Text
Output Date value as date type that is regionalized and formatted

DateValue() function examples

Example 1

Using DateValue() to create a date object out of text, format and region.

Binding {{DateValue("2020/10/22","yyyy/MM/dd","en-US")}}
Output 2020-10-22 (As a date object)

  Note

The date and formatting need to match (the order of day, month and year).
So {{DateValue("2020/10/22","yyyy/MM/dd","en-US")}} shown in the example above works, but {{DateValue("2020/10/22","dd/MM/yyyy","en-US")}} does not work
.

Example 2

Using DateValue() to create a date object out of text, format and region.

Binding {{DateValue("Oct 22th, 2020","MMM d'th,' yyyy","en-US")}}
Output 2020-10-22 (As a date object)

Example 3

Using DateValue() in combination with HostSystem to transform a date in text originating from an external system, and convert it to a date object.

Binding {{DateValue(HostSystem.Date,"MMM d'th,' yyyy","en-US")}}
Input "Oct 11th, 2020"
Output 2020-10-11 (As a date object)
default value general number tech_role
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.