DateTime
- retrieves encoded date time

Date/Time
(AmiBroker 4.30)


SYNTAX DateTime()
RETURNS ARRAY
FUNCTION Returns array of encoded date/time values suitable for using with AddColumn and formatDateTime constant to produce date time formated according to your system settings.

VERSION 5.27 and above: It is important to understand that DateTime is not a simple number but rather bitset and two datetime values can only be reliably compared for equlity or inequality using == or != operators. Any other comparisions (less than/greater then) using normal operators > < can lead to wrong results, therefore to compare two datetime numbers you should use DateTimeDiff( arg1, arg2 ) which will return positive values if arg1 > arg2 and negative values if arg1 < arg2.

EXAMPLE 1. Simple date/time column

AddColumn( DateTime(), "Date / Time", formatDateTime );

2. Example (produces signal file accepted by various other programs):

Buy=Cross(MACD(),Signal());
Sell=Cross(Signal(), MACD());
Filter=Buy OR Sell;
SetOption("NoDefaultColumns", True );
AddColumn( DateTime(), "Date", formatDateTime );
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar );

SEE ALSO

References:

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

More information:

See updated/extended version on-line.