Mendix 7 is no longer supported unless you have Extended Support (for details, please contact Mendix Support). Mendix 7 documentation will remain available for customers with Extended Support until July, 2024.

Parse and Format Date Function Calls

Last modified: April 5, 2024

Functions to parse datetimes from strings, using a specified pattern, or produce a string from a datetime.

See SimpleDateFormat for all pattern possibilities.

parseDateTime[UTC]

Takes a string and tries to parse it. If it fails and a default value is specified, it returns the default value. Otherwise, an error is raised. The function parseDateTime uses the user’s time zone and parseDateTimeUTC uses the UTC calendar.

Input parameters

  • a date Type: String
  • a format Type: String
  • a default value (optional) Type: DateTime

Output

The parsed date, or the default value if a date could not be parsed. Type: DateTime

1
parseDateTime('2015-05-21', 'yyyy-MM-dd')

returns

1
The date May 21, 2015\. The time will be 12 o'clock at night because it is not specified.
1
parseDateTime('noDateTime', 'dd-MM-yyyy', dateTime(2007))

returns

1
'Mon Jan 01 00:00:00 CET 2007'

formatDateTime[UTC]

Converts the datetime to a string, formatted according to the format parameter. Without the format parameter, a standard format is used. The function formatDateTime uses the users calendar and formatDateTimeUTC uses the UTC calendar.

Input parameters

  • a date Type: DateTime
  • a format (optional) Type: String

Output

A formatted representation of the datetime. Type: String

1
formatDateTime($object/Date1,'EEE, d MMM yyyy HH:mm:ss Z')

returns:

1
'Sun, 8 Jun 2008 10:12:01 +0200'

To get ‘1987-12-31T23:59:00’, you need to concatenate two formatDateTime[UTC] functions:

1
formatDateTime($object/Date1,'yyyy-MM-dd') + 'T' + formatDateTime($object/Date1,'HH:mm:ss')

formatTime[UTC]

Converts the time part of datetime to a string in a standard format. formatTime uses the users calendar and formatTimeUTC uses the UTC calendar.

Input parameters

  • a date Type: DateTime

Output

A formatted representation of the time part of the datetime value. Type: String

1
formatTime(dateTime(1974, 7, 2, 9, 50, 10))

returns:

1
'9:50 AM'

formatDate[UTC]

Converts the date part of datetime to a string in a standard format. formatDate uses the users calendar and formatDateUTC uses the UTC calendar.

Input parameters

  • a date Type: DateTime

Output

A formatted representation of the date part of the datetime value. Type: String

1
formatDate(dateTime(1974, 7, 2, 9, 50, 10))

returns:

1
'7/2/74'