TtoC function

Official Content
This documentation is valid for:

Returns a character type value representing the DateTime parameter, which format is specified by DateDigits and HourDigits.

Syntax

TtoC( datetime-expression [, DateDigits [, HourDigits]] )

Type returned:
Character

Where:
The possible values for DateDigits and HourDigits are the same used for the DateTime data type definition.

Possible values for DateDigits are:

DateDigits   Description
0 The date part is not included in the resulting string.
8 The date part is included in the resulting string in 8 digits (99/99/99) following the date format rules.
10 The date part is included in the resulting string in 10 digits (99/99/9999) following the date format rules.

 

HourDigits    Description
0 Only the date part is obtained
2 Only the time part is displayed in 24-hour format
5 Hour and minutes are included in the resulting string separated by the time separator symbol. The 24-hour format is used
8 Hour, minutes and seconds are included in the resulting string with the hour/minute and minute/second separator. The 24-hour format is used
12 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

Notes

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.

Example

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

new
DT8 = ymdhmstot(82,03,24,13,25,10) //create a datetime 24/03/82 13:25:10
endnew

for each
&character = ttoc(DT8)
msg(&character) //will show the string 24/03/82 13:25:10
endfor

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

Scope

Objects   Procedure object, Transaction object, Web Panel object

See also