- convert datetime to string

(AmiBroker 4.80)

SYNTAX DateTimeToStr( NUMBER, mode = 0 )
FUNCTION Converts number representing date/time value (for example obtained using GetCursorXPosition(), Now(), DateTime() functions) to the corresponding STRING (text).

The mode parameter defines the output mode:

  • 0 - convert both date and time portion
  • 1 - only date
  • 2 - only time.
  • 3 - iso date and time YYYY-MM-DD HH:MM:SS) HH:MM:SS part is only included for non-EOD records
  • 4 - iso date only YYYY-MM-DD
  • 5 - iso time only HH:MM:SS
Note that mode 2 would give you empty string when applied on chart with daily or longer interval
EXAMPLE ToolTip="X="+DateTimeToStr(GetCursorXPosition())
SEE ALSO DATETIME() function , NOW() function , StrToDateTime() function , DateTimeFormat() function


The DateTimeToStr function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.