Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Average calculating on date columns
Message
De
13/10/2008 07:08:10
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01354514
Message ID:
01354516
Vues:
12
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform