Nevermind, we were calculating workdays, not weeks.

maybe the algorithm is helpful:


<@ASSIGN local$sDs VALUE="<@DATETOSECS DATE='<@ARG sDate>'>">
<@ASSIGN NAME="NbrDays" VALUE='<@DATEDIFF DATE1="<@ARG eDate>" DATE2="<@ARG sDate>">' SCOPE="local">
<@ASSIGN NAME="WorkDays" VALUE='0' SCOPE="local">
<@IF EXPR="@@local$NbrDays > 0">
    <@FOR START="1" STEP="1" STOP="@@local$NbrDays">
       <@ASSIGN NAME="DOW" VALUE='<@FORMAT STR="<@SECSTODATE SECS='@@local$sDs'>" FORMAT="datetime:%w">' SCOPE="local">
        <@IF EXPR='@@local$DOW != 0 && @@local$DOW != 6' TRUE="<@ASSIGN local$WorkDays VALUE='<@CALC EXPR="@@local$WorkDays + 1">'>">
        <@ASSIGN local$sDs VALUE='<@CALC EXPR="@@local$sDs + 86400">'>
    </@FOR>
<@ELSE>
    <@ASSIGN local$NbrDays 1>
    <@IF EXPR='<@FORMAT STR="<@ARG sDate>" FORMAT="datetime:%w"> != 0' TRUE="<@ASSIGN local$WorkDays VALUE='<@CALC EXPR="@@local$WorkDays + 1">'>">
</@IF>


from <@ARG sDate> to <@ARG eDate> <br>
Total Days @@local$NbrDays <br>
Total Work Days @@local$WorkDays<br>
<br>
Time Elapsed: <@calc "<@TIMER>/1000"> Seconds


-- 

Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040

On Aug 3, 2005, at 9:45 AM, Robert Garcia wrote:

It was a long time ago, but ben and I tested some methods for this type of stuff, and tested as taf, tcf, and bean, and posted results and methods. Couple years ago I think. Search the archives.

-- 

Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040

On Aug 3, 2005, at 9:32 AM, Brian Domine ((bdomine)) wrote:

Is there anyway to calculate the number of weeks between 2 given dates, similar to how you get the number of days between two dates using @datediff?
 
I can do it by formating the two dates into a numerical week value and calculating the difference, but this won't work if its spanning years, any advice would be helpful. Thanks
 
Brian
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf


________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to