I have small issue?
how 2 convert days in to weeks ?
i know days/7
but client needed like 1 week 3 days = 1.3,
1 week 4 days = 1.4
1 week 5 days = 1.5
1 week 6 days = 1.6
2 week = 2
?
I have small issue?
how 2 convert days in to weeks ?
i know days/7
but client needed like 1 week 3 days = 1.3,
1 week 4 days = 1.4
1 week 5 days = 1.5
1 week 6 days = 1.6
2 week = 2
?
See mod and div arithmetic operators.
In your case, use can use for example
weeks = days div 7 + ((days mod 7) * 0.1);
Hello Ven,
You can make use of the following functions to convert the number of days to weeks as per your requirement:
div
i = 100 div 21;
Returns the integer division of 100 by 21. i=4 (4*21 = 84, remainder 16).
mod
i = 100 mod 21;
Returns the remainder of the integer division of 100 by 21. i=16.
int2Str Function
Converts an integer to the equivalent text string.
str int2Str(int integer)
str2Num Function
Converts a text string to a real number. Scanning occurs from left to right and terminates when a character cannot be converted to part of a real number.
real str2Num(str _text)
Suppose you have X days. Calculate the number of weeks by using div function (Y = X div 7), calculate the number of remainder days by using the mod function (Z = X mod 7). Make a string (lets say S) such that S = int2str(Y) + ‘.’ + int2str(Z);. Return the required number of weeks str2num(S).
Hello Ven,
The solution I have advised to you can also be used when you don’t know that after using the mod function (like C = A mod B) how many digits the result C will contain (1,2 or 3 or more).