>Hi All,
>i am trying to calculate average of dates
>first i've tried in excel like below
>
> =sum(a1:a8)/12 && 12 row count
>and excel gives me for eg. 11.02.2008
> same thing in VFP doesnt work like sum(actDate)/cnt(*) naturally but i've also tried
> avg(),eval() etc. functions but was not succesfull so ;
>
> how can i calculate average of dates like excel in VFP ?
>
>TIA
avg only works on numbers
So,
- the date has to be converted to a number with an offset
- the avg works on that number
- the offset has to be added to the avg
create cursor xx ;
( actDate D )
for i = 0 to 11
insert into xx values ({^2008/03/01} + m.i )
endfor
select ceiling(avg(actDate - date())) + date() as avg_date ;
from xx
Gregory