Returns a date formatted as a string.
Category: | Date and Time |
Returned data type: | String |
Note: | The returned value is a string with the date formatted as a string. |
formatdate(<datevar,format>)
<datevar>
a date that needs to be formatted; this can be specified as field name
<format>
a string that represents the format that needs to be applied; this can be specified as fixed string, field name, or expression
The format parameter can include any string, but the following strings are replaced with the specified values:
Note: The format parameters are case sensitive.
The formatdate function dates should be in the format specified by ISO 8601 (YYYY-MM-DD hh:mm:ss:ms) to avoid ambiguity. Remember that date types must start with and end with the # sign (for example, #12-February-2010#).
// Declare a date variable and initialize
// it to a value
date dateval
dateval = #2010-02-12#
// Declare the formatted date variable
string fmtdate
fmtdate = formatdate(dteval, "MM/DD/YY")
Results: 02/12/10
// Declare a date variable and initialize
// it to a value
date dateval
dateval = #2010-02-12#
// Declare the formatted date variable
string fmtdate
fmtdate = formatdate(dateval, "DD MMM YYYY")
Results: February 12, 2010 12 Feb 2010
// Declare a date variable and initialize
// it to a value
date dateval
dateval = #2010-02-12#
// Declare the formatted date variable
string fmtdate
fmtdate = formatdate(dateval, "MMMM DD, YYYY")
Results: February 12, 2010
day_string=formatdate('date',"DD");
month_string=formatdate('date',"MM");
year_string=formatdate('date',"YYYY");
int_number='date';
date_string=formatdate(int_number,"MMM DD,YYYY");
df_date='date';
Results:
![]()