Skip Navigation Links
xFDN Home
Contributions

Handle Date/Time Format Conversions within xFusion

Author: Sheetal Dehadaraya, Software Labs Inc.

This article shows the most common conversions between DateTime type field and textual (string) formats. To convert from string type to DateTime type field, use function ToDate a nd to convert from DateTime type field to string type, use functionFormat. For Internaltional use, you can also specify language-specific text conversion using function CultureFormat. These functions can be found under the category Conversion Functions. Here are some examples:
ToDate('20031118', 'yyyyMMdd') as Date
Converts the string in parameter to date specified in the second format.
ToDate(Now(), "yyyyMMddHms") as Date
Returns current time as date-time string with specified format mentioned in second parameter.

DateTime format specifications can be categorized into two groups - standard and custom. Using standard formats, xFusion will do the interpretation. Using custom format, you specify the exact format.

Here is the list of most common standard formats that are used:
Format specifier Name Description

d

Short date pattern

Represents a custom DateTime format string.

For example, the custom format string for the invariant culture is "MM/dd/yyyy".

D

Long date pattern

Represents a custom DateTime format string.

For example, the custom format string for the invariant culture is "dddd, dd MMMM yyyy".

f

Full date/time pattern (short time)

Represents a combination of the long date (D) and short time (t) patterns, separated by a space.

F

Full date/time pattern (long time)

Represents a custom DateTime format string.

For example, the custom format string for the invariant culture is "dddd, dd MMMM yyyy HH:mm:ss".

g

General date/time pattern (short time)

Represents a combination of the short date (d) and short time (t) patterns, separated by a space.

G

General date/time pattern (long time)

Represents a combination of the short date (d) and long time (T) patterns, separated by a space.

M or m

Month day pattern

Represents a custom DateTime format string.

For example, the custom format string for the invariant culture is "MMMM dd".


Click here for a comprehensive list of standard date-time formats.

Here is a list of most common custom formats that are used:
Format specifier Description

m

Represents the minute as a number from 0 through 59. The minute represents whole minutes passed since the last hour. A single-digit minute is formatted without a leading zero.

mm, mm (plus any number of additional "m" specifiers)

Represents the minute as a number from 00 through 59. The minute represents whole minutes passed since the last hour. A single-digit minute is formatted with a leading zero.

M

Represents the month as a number from 1 through 12. A single-digit month is formatted without a leading zero.

MM

Represents the month as a number from 01 through 12. A single-digit month is formatted with a leading zero.

MMM

Represents the abbreviated name of the month.

MMMM

Represents the full name of the month.


Click here for a comprehensive list of custom date-time formats.

Click here to download a sample fusion pack. This fusion pack shows some examples handling multiple date-time formats.
©2010 Software Labs, Inc.