title | url | canonical_url | description |
---|---|---|---|
Parse and Format Date Function Calls |
/refguide7/parse-and-format-date-function-calls/ |
Describes the functions for parsing datetimes from strings using a specified pattern or producing a string from a datetime in Mendix. |
Functions to parse datetimes from strings, using a specified pattern, or produce a string from a datetime.
See SimpleDateFormat for all pattern possibilities.
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.
- a date Type: String
- a format Type: String
- a default value (optional) Type: DateTime
The parsed date, or the default value if a date could not be parsed. Type: DateTime
parseDateTime('2015-05-21', 'yyyy-MM-dd')
returns
The date May 21, 2015\. The time will be 12 o'clock at night because it is not specified.
parseDateTime('noDateTime', 'dd-MM-yyyy', dateTime(2007))
returns
'Mon Jan 01 00:00:00 CET 2007'
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.
- a date Type: DateTime
- a format (optional) Type: String
A formatted representation of the datetime. Type: String
formatDateTime($object/Date1,'EEE, d MMM yyyy HH:mm:ss Z')
returns:
'Sun, 8 Jun 2008 10:12:01 +0200'
To get '1987-12-31T23:59:00', you need to concatenate two formatDateTime[UTC] functions:
formatDateTime($object/Date1,'yyyy-MM-dd') + 'T' + formatDateTime($object/Date1,'HH:mm:ss')
Converts the time part of datetime to a string in a standard format. formatTime
uses the users calendar and formatTimeUTC
uses the UTC calendar.
- a date Type: DateTime
A formatted representation of the time part of the datetime value. Type: String
formatTime(dateTime(1974, 7, 2, 9, 50, 10))
returns:
'9:50 AM'
Converts the date part of datetime to a string in a standard format. formatDate
uses the users calendar and formatDateUTC
uses the UTC calendar.
- a date Type: DateTime
A formatted representation of the date part of the datetime value. Type: String
formatDate(dateTime(1974, 7, 2, 9, 50, 10))
returns:
'7/2/74'