Question : Calculate current percentage of month that has elapsed

How do I calculate the percentage of a month that has gone by until the current time?

What we want to do is compare prior month sales to current month sales.  Since months vary in length, we are going to use the percentage of this month that has elapsed so far compared to that percentage of last month.

Ideas?

Thanks

Answer : Calculate current percentage of month that has elapsed

Percentage up to yesterday(completed day)

1.0*(datepart(d,getdate())-1) / datepart(d,dateadd(m,datediff(m,0,getdate())+1,0)-1)

Percentage up to current time of day (including part day, reasonable for 24/7..)

1.0*(datepart(d,getdate())-1+convert(float,getdate())-convert(int,getdate())) / datepart(d,dateadd(m,datediff(m,0,getdate())+1,0)-1)

We do this all the time, a % while maybe skewed at times is better than most alternatives.
Random Solutions  
 
programming4us programming4us