This statement applies a display format to a date value and returns Jan 31, 2002:
String(2002-01-31, "mmm dd, yyyy")
This example applies a format to the value in order_date and sets date1 to 6-11-02:
Date order_date = 2002-06-11
string date1
date1 = String(order_date,"m-d-yy")
This example includes a format for a null date value so that when order_date is null, date1 is set to none:
Date order_date = 2002-06-11
string date1
SetNull(order_date)
date1 = String(order_date, "m-d-yy;'none'")
This statement applies a format to a DateTime value and returns Jan 31, 2001 6 hrs and 8 min:
String(DateTime(2001-01-31, 06:08:00), &
'mmm dd, yyyy h "hrs and" m "min"')
This example builds a DateTime value from the system date and time using the Today and Now functions. The String function applies formatting and sets the text of sle_date to that value, for example, 6-11-02 8:06 pm:
DateTime sys_datetime
string datetime1
sys_datetime = DateTime(Today(), Now())
sle_date.text = String(sys_datetime, &
"m-d-yy h:mm am/pm;'none'")
This statement applies a format to a numeric value and returns $5.00:
String(5,"$#,##0.00")
These statements set string1 to 0123:
integer nbr = 123
string string1
string1 = String(nbr,"0000;(000);****;empty")
These statements set string1 to (123):
integer nbr = -123
string string1
string1 = String(nbr,"000;(000);****;empty")
These statements set string1 to ****:
integer nbr = 0
string string1
string1 = String(nbr,"0000;(000);****;empty")
These statements set string1 to "empty":
integer nbr
string string1
SetNull(nbr)
string1 = String(nbr,"0000;(000);****;empty")
This statement formats string data and returns A-B-C. The display format assigns a character in the source string to each @ and inserts other characters in the format at the appropriate positions:
String("ABC", "@-@-@")
This statement returns A*B:
String("ABC", "@*@")
This statement returns ABC:
String("ABC", "@@@")
This statement returns a space:
String("ABC", " ")
This statement applies a display format to time data and returns 6 hrs and 8 min: