Rounding up to whole number

Analytics
Enthusiast

Rounding up to whole number

I have a calculation where I'm subtracting dates, and then dividing by 7 to get the number of weeks in that time span; then this number is being multiplied by a dollar amount.

My question is, how do I round up? For instance, if my calculation is 54.14, I actually want it to be 55 and then multiply that number by the dollar amount.

Here is what I have so far, and it is working great except for the rounding issue.

((((End_Date - Start_Date) + 1)/7) * DollarAmount)

Is there a function that I can use that ensure the (((End_Date - Start_Date) + 1)/7) round up to the next whole number?

Thank you for your help!
4 REPLIES
Enthusiast

Re: Rounding up to whole number

Use that expression :
cast((((End_Date - Start_Date) / 7) + 1) as integer)
Enthusiast

Re: Rounding up to whole number

I guess, by default date - date would return integer... So, another casting to interger may not be required
Enthusiast

Re: Rounding up to whole number

Ok, you are correct, this is already rounding. I'll do a few test cases to see if it is always rounding up or to the nearest whole number. Thank you for your replies!
Enthusiast

Re: Rounding up to whole number

I have an scenarios that would like to round up a number left by 1 digit. for example, i have a number 35 and i would like the result round left 1 digit will be 3 a following:

first digit second digit
3 3
round this up
4