Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Query add data: Calculating a number that should be a floating point evaulates to 2 zeros as decimals

Avatar

Level 3

Hi there! 

 

I have a use case where I want to find out the week number of the year. To do that I am using the following formula using built-in JS functions from ACC: Ceil((WeekDay(GetDate())+1 + DayOfYear(GetDate())) / 7)

However! It seems that when dividing a number that would lead to a decimal number like: 21,58 - This does not work, since ACC always returns 21,00 no matter the subsequent digits. 

 

So that of course gives me the wrong result from the formula. 

 

Any chance someone knows why this happens, and how to fix that?? 

See images for reference. 

 

image.pngimage.pngimage.png

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hello @SorenDahk ,

it's because SQL performs integer division.

you have to ''trick'' sql into thinking that on your division ther is at least one float.

Try this : ToDouble(151)/7 

or this with your formula : Ceil(ToDouble((WeekDay(GetDate())+1 + DayOfYear(GetDate()))) / 7)

results : 

Amine_Abedour_0-1653385677952.png

Br,

View solution in original post

2 Replies

Avatar

Correct answer by
Level 4

Hello @SorenDahk ,

it's because SQL performs integer division.

you have to ''trick'' sql into thinking that on your division ther is at least one float.

Try this : ToDouble(151)/7 

or this with your formula : Ceil(ToDouble((WeekDay(GetDate())+1 + DayOfYear(GetDate()))) / 7)

results : 

Amine_Abedour_0-1653385677952.png

Br,