About this article
FormatDateTime() is a function that formats dates and time according to a date format and language.
Prerequisites
|
Syntax
There are two different syntaxes for FormatDateTime(), one taking 3 parameters and the second taking 5 parameters. The first syntax is if your date is already a Date object such as one that has been converted using DateValue() or coming from a date form field. The second syntax takes text values and converts them to a date object in the background and then formats the date. This is typically used for external systems such as Salesforce.
Syntax 1
The syntax if you already have your date as a date object. The Language
is designated using a BCP 47 language tag and will determine the language used for expressing days and months. The Format
follows the .NET standard referenced in the article on date formats.
Syntax | {{FormatDateTime(Date,Format,Language)}} |
Input | date, text, text |
Output | DateTime formatted according to format and language |
Example 1
Use a date form field to insert text in a text binding that formats according to dddd d MMMM yyyy
for the en-US
language. The language setting is expressed in the output being Thursday
and November
.
Binding | {{FormatDateTime(Form.Date,"dddd d MMMM yyyy","en-US")}} |
Input |
Form.Date = 2020-11-12 |
Output | "Thursday 12 November 2020" |
Syntax 2
The syntax if you need to convert text to a date object automatically in the background. ResultFormat
and SourceFormat
follow the .NET standard. ResultLanguage
and SourceLanguage
are designated by BCP 47 language tags and determine the input and output of days and months.
Syntax | {{FormatDateTime(DateTimeText,ResultFormat,ResultLanguage,SourceFormat, SourceLanguage)}} |
Input | text, text, text, text, text |
Output | DateTime formatted according to format and region |
Example 1
Converting a date from a text form field with a source format of MMM d'th,' yyyy
with language en-US
to a result format of dddd d MMMM yyyy
with language nl-NL
(Dutch)
Binding | {{FormatDateTime(Form.SomeDates.Name,"dddd d MMMM yyyy","nl-NL","MMM d'th,' yyyy","en-US")}} |
Input |
Form.SomeDates.Name = Oct 22th, 2020 ResultFormat = "dddd d MMMM yyyy" |
Output | "donderdag 22 oktober 2020" |
Comments
0 comments
Article is closed for comments.