GetDateTimeFormat
Reformats a date-time string using a specific format and culture.
Syntax
GetDateTimeFormat( OutputFormat, OutputCulture, InitialDateTime, InputCulture );
Parameters
Parameter Name | Type | Description | Optional? | Default Value |
---|---|---|---|---|
OutputFormat | String | The format in which the modified date-time will appear. While this parameter is not optional, supplying an empty string will cause the function to use "d". | No | n/a |
OutputCulture | String | The intended culture code for the function's result. While this parameter is not optional, supplying an empty string will cause the function to use the culture of the model that called it, where available. | No | n/a |
InitialDateTime | String | A valid date-time. If omitted, or if the value provided is not recognised, the function will return the current date and time. | Yes | "" |
InputCulture | String | The culture code of the initial date and time. If omitted or left blank, the function will use the culture of the model that called it, where available. | Yes | "" |
Output
If successful, the function will return a string consisting of the modified date-time. If the OutputCulture or InputCulture are invalid, the function will return an error.
Use Case
A travel operator's website collects booking details from customers around the world. To produce meaningful reports on the requirements of their customers, all bookings need to have dates in a consistent culture as well as in the native culture of the person who made the booking.
To convert this data and produce a list of consistent dates, a table containing dates in their native culture, alongside the culture itself, is sent to a data analyst. An example is shown below:
NativeDate | NativeCulture |
---|---|
23/09/2014 12:58:03 | fr-FR |
9/23/2014 12:58:03 PM | en-US |
2014/09/23 12:58:03 | ja-JP |
For each row of the table, the analyst uses the following expression to populate a third column, ConvertedDate, which contains dates in the en-GB format:
ConvertedDate = GetDateTimeFormat("", "en-GB", NativeDate, NativeCulture);
Since the first argument is left blank in this example, the function uses the default value of "d" to produce date-times such as 23/09/2014 12:58:03.