Skip to main content
Version: 7.9

This function is used in Python Scripting.


Returns the given date as a string and formatted according to a pattern. The pattern is a format that is full of various placeholders that display different parts of the date. These are case-sensitive. These placeholders can be repeated for a different effect. For example, M will give you 1-12, MM will give you 01-12, MMM will give you Jan-Dec, MMMM will give you January-December. The placeholders are:

SymbolDescriptionPresentationExamplesOther Notes
GEra designatorTextG=AD
yYearYearyyyy=1996; yy=96Lowercase y is the most commonly used year symbol
YWeek yearYearYYYY=2009; YY=09Capital Y gives the year based on weeks (ie. changes to the new year up to a week early)
MMonth in yearMonthMMMM=July; MMM=Jul; MM=07
wWeek in yearNumber27If Dec31 is mid-week, it will be in week 1 of the next year
WWeek in monthNumber2
DDay in yearNumber189
dDay in monthNumber10
FDay of week in monthNumber22nd Sunday of the month
EDay name in weekTexEEEE=Tuesday; E=Tue
uDay number of weekNumber1(1 = Monday, ..., 7 = Sunday)
aAm/Pm markerTextPM
HHour in day (0-23)Number0
hHour in am/pm (1-12)Number12
kHour in day (1-24)Number24
KHour in am/pm (0-11)Number0
mMinute in hourNumber30
sSecond in minuteNumber55
zTime zoneGeneral time zonezzzz=Pacific Standard Time; z=PST
ZTime zoneRFC 822 time zoneZ=-0800
XTime zoneISO 8601 time zoneX=-08; XX=-0800; XXX=-08:00
Expert Tip

This function uses the Java class java.text.SimpleDateFormat internally, and will accept any valid format string for that class.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax, format)


DatedateThe date to format.
StringformatA format string such as "yyyy-MM-dd HH:mm:ss". The format argument is optional. The default is "yyyy-MM-dd HH:mm:ss". Refer to Data Type Formatting Reference for a table of acceptable symbols.


String - A string representing the formatted datetime.



Code Examples

Example #1
# This example would format the current date to look like "01/01/01"

today =
print, "yy/MM/dd")
#This printed 16/04/01
Example #2
# This example would format the current date to look like "2001-01-31 16:59:59"
# This is a standard format that all databases recognize.

today =
print, "yyyy-MM-dd HH:mm:ss")