[thelist] declaring once verse not

Joe LaChapell lacjoe at wsinc.com
Thu Aug 14 09:01:12 CDT 2003


FWIW, you could replace your entire if/else with:
currentquarter = "Q" + ceil(curmonth / 3);
(or whatever the syntax is for ASP).

To answer your question, set the var once and call it everytime.

-joe

Gary Swanson wrote:

> I have online app that is looking at the current month and determining what
> quarter it is.  IE Q3
> 
> I am doing this with a simple else if
> 
> curmonth = month(date())
> 
> if curmonth >=1 AND curmonth<4 then
>     currentquarter = "Q1"
> elseif curmonth>=4 AND curmonth<7 then
>     currentquarter = "Q2"
> elseif curmonth>=7 AND curmonth<10 then
>     currentquarter = "Q3"
> elseif curmonth>=10 AND curmonth<=12 then
>     currentquarter = "Q4"
> end if
> 
> This got me wondering ... does it take less processor usage to set a
> variable once and call it everytime, or to just repeat the month function
> for each use.
> 1.
> curmonth = month(date())
>     check curmonth
>     check curmonth
>     check curmonth
> 2.
>     check month(date())
>     check month(date())
>     check month(date())
> 
> Though there is probably no great difference in this one use, would it add
> up if one style is used alot over another?
> 
> Any ideas?
> 
> TIA
> 



More information about the thelist mailing list