Formating timenum() function value

The timenum() returns the value as : 101155

Can we get the value as 10 : 11 : 55

Please help with the code if it is possible.

It's easy if you use DateTime() instead of Timenum(). In such case you can use DateTimeToStr() :

printf( "\nDate and Time --> " + DateTimeToStr( SelectedValue( DateTime() ), 3 ) );
printf( "\n\nOnly Time --> " + DateTimeToStr( SelectedValue( DateTime() ), 5 ) );

Przechwytywanie

https://www.amibroker.com/guide/afl/datetimetostr.html
https://www.amibroker.com/guide/afl/datetimeformat.html

4 Likes

Thanks a lot.

You made my DAY!!!

1 Like

Just a little thing again:

PL1 = ValueWhen( signum == signumstart1 , vs,1 );

The above code gives result as 9.845621 for example. But I want only 2 places after decimal.
Please let me know how to do it.

Use Prec() function.

https://www.amibroker.com/guide/afl/prec.html