Datetime formatting occurs when converting a DATETIME to a string, for example in a LET, DISPLAY or PRINT instruction, and when displaying datetime values in form fields.
yyyy-mm-dd hh:mm:ss.fffff
The next example formats a DATETIME value by using the util.Datetime.format() method:
IMPORT util MAIN DEFINE dt DATETIME YEAR TO SECOND LET dt = CURRENT DISPLAY util.Datetime.format(dt, "%Y-%m-%d %H:%M:%S") END MAIN
2015-12-23 11:45:33
A datetime value can be formatted with the util.Datetime.format() method.
DEFINE dt DATETIME YEAR TO FRACTION(5) LET dt = "2015-12-24 11:34:56.82373"
DEFINE dt DATETIME YEAR TO MINUTE LET dt = util.Datetime.parse( "2014-12-24 23:45", "%Y-%m-%d %H:%M" )
When formatting DATETIME values, the format-string of the util.Datetime.parse() and util.Datetime.format() methods consists of a set of place holders that represent the different parts of a datetime value (year, month, day, hour, minute, second and fraction).
s shows the formatting symbols for DATETIME expressions. Any character different from the placeholders described in this table is interpreted as a literal and will appear as-is in the resulting string.
The calendar used for date formatting is the Gregorian calendar.
| Placeholder | Description | 
|---|---|
| %a | The abbreviated name of the day of the week. Note: When parsing a datetime string,
                                %a and %A are equivalent to detect
                                the name of the day of the week in abbreviated form or full day
                                name. 
 | 
| %A | The full name of the day of the week. | 
| %b or %h | The abbreviated month name. Note: When parsing a datetime
                                string, %b/%h and
                                %B are equivalent to detect the month name in
                                abbreviated form or full month name. 
 | 
| %B | The full month name. | 
| %c | The date and time representation. | 
| %C | The century number (0-99) | 
| %D | Equivalent to %m/%d/%y | 
| %d | The day of month with 2 digits (01-31) | 
| %e | The day of month with one or 2 digits (1-31) | 
| %F | The fractional part of a second | 
| %H | The hour with 2 digits (00-23). | 
| %I | The hour on a 12-hour clock (1-12) | 
| %y | The year on 2 digits (91) | 
| %Y | The year on 4 digits (1991) | 
| %m | The month as 2 digits (01-12) | 
| %M | The minutes (00-59) | 
| %n | A newline character | 
| %p | The locale's equivalent of AM or PM | 
| %r | The 12-hour clock time. In the POSIX locale equivalent to %I:%M:%S %p | 
| %R | Equivalent to %H:%M | 
| %S | The seconds (00-59) | 
| %t | A tab character | 
| %T | Equivalent to %H:%M:%S | 
| %x | The date, using the locale's date format. | 
| %X | The time, using the locale's time format. | 
| %w | The ordinal number of the day of the week (0-6), with Sunday = 0. | 
| %y | The year within century (0-99) | 
| %Y | The year, including the century (for example, 1991) | 
| Format String | Datetime value | Result string | 
|---|---|---|
| %d/%m/%Y %H:%M | 2011-10-24 11:23:45 | 24/10/2011 11:23 | 
| [%d %b %Y %H:%M:%S] | 2011-10-24 11:23:45 | [24 Oct 2011 11:23:45] | 
| (%a.) %b. %d, %Y | 1999-09-23 | (Thu.) Sep. 23, 1999 |