Basically you have to turn each part of your time value (which you can turn into a string using FORMAT), into a separate number and use this for a number.
It isn't possible to use the function StrToInt bcs it is not useable in Navision. So I try to use the functions EVALUATE, STRSUBSTNO, FORMAT to change the type of the timevalue into a stringformat. but none off them works!
he always gives an error that typeconversion is not possible from Time to Text.
Must that be possible I can follow your syntax to spilt it up in hours, minutes and seconds.
If you subtract two C/AL Time variables, you get an Integer that contains the number of milliseconds between the two Times. So, you can use the following code to go from a Time to a Decimal:
// convert time to milliseconds...
intMilliSecondsSinceMidnight := MyTime - 000000T;
// throw away seconds and milliseconds...
intMinutesSinceMidnight := ROUND(intMilliSecondsSinceMidnight,1000*60);
// convert to decimal hours (minutes represented as decimal fraction)
decHours := intMinutesSinceMidnight / 60;
Comments
using '12:05:10 AM'
4 variables, for hour, minute, second and the AM/PM are filled with the 4 values
use the EVALUATE function to make sure you get numeric numbers (not text) for the first 3.
If PM, add 12 to the hour variable.
Then, what do you want? A total number of seconds? This would be easy, multiple the minutes by 60 and the hours by 3600, then add them all together.
If you want minutes multiply the hours by 60 and divide the seconds by 60 and add them all together.
-a
you have a variable with a time value in it.
timeVar := 10:20:00
i want to get the decimal value
in this way
decimalVar = 10,20
so you can you convert that timeVar into a DecimalVar
hope you can handle that problem.
Basically you have to turn each part of your time value (which you can turn into a string using FORMAT), into a separate number and use this for a number.
tTime := FORMAT(10:20:00)
dHour := StrToInt(copy(tTime, 1, 2))
dMinute := StrToInt(copy(tTime, 3, 2))
dSecond := StrToInt(Copy(tTime, 5, 2))
dResult := dHour + (dMinute / 60) + (dSecond / 3600)
I didn't check this, just wrote it off the top of my head.
but it doesn't work.
It isn't possible to use the function StrToInt bcs it is not useable in Navision. So I try to use the functions EVALUATE, STRSUBSTNO, FORMAT to change the type of the timevalue into a stringformat. but none off them works!
he always gives an error that typeconversion is not possible from Time to Text.
Must that be possible I can follow your syntax to spilt it up in hours, minutes and seconds.
hope you have an other suggestion