Returns a character type value representing the DateTime parameter, which format is specified by DateDigits and HourDigits.
TtoC( datetime-expression [, DateDigits [, HourDigits]] )
The possible values for DateDigits and HourDigits are the same used for the DateTime data type definition.
Possible values for DateDigits are:
||The date part is not included in the resulting string.
||The date part is included in the resulting string in 8 digits (99/99/99) following the date format rules.
||The date part is included in the resulting string in 10 digits (99/99/9999) following the date format rules.
||Only the date part is obtained
||Only the time part is displayed in 24-hour format
||Hour and minutes are included in the resulting string separated by the time separator symbol. The 24-hour format is used
||Hour, minutes and seconds are included in the resulting string with the hour/minute and minute/second separator. The 24-hour format is used
||The complete time is included in the resulting string (including milliseconds) with the hour/minute, minute/second and second/millisecond separator. The 24-hour format is used
In case DateDigits and/or HourDigits are omitted, their default values are the ones used for the DateTime parameter definition (first parameter).
In case the m/n combination is not valid, these values are assumed: DateDigits =10 and HourDigits=8.
The returned string format is the same one expected by CtoT function. That is, the date part depends on the Date format in CTOD function property and the time part is always in 24-hour format.
If you need to obtain the date part of a DateTime expression you can simply assign it to a Date expression (Date = DateTime).
For instance, if InvDate is a Date-based attribute and Timestamp is a DateTime-based attribute, you can do:
InvDate = Timestamp
For example, we can get a DateTime from a previously stored record, convert it to string and show on screen
DT8 = ymdhmstot(82,03,24,13,25,10) //create a datetime 24/03/82 13:25:10
&character = ttoc(DT8)
msg(&character) //will show the string 24/03/82 13:25:10
Sample using Milliseconds precision:
&DT = CtoT('09/09/1999 14:35:30.450')
&STR = TtoC(&DT,10,8) //==> 09/09/1999 02:35:30 PM
&STR = TtoC(&DT,10,12) //==> 09/09/1999 02:35:30.450 PM
Objects Procedure object, Transaction object, Web Panel object