|
-
May 19th, 2010, 10:12 AM
#1
Thread Starter
Member
[RESOLVED] Calculate Fields in Domain Aggregate Functions using DateDiff
I have a table tblDocInfo which I made a continuous form with the fields
PurchaseOrderApprovalDate and ActualDeliveryDate and primary key docID (autonumber). I have a calculated control difTargetOutputStep1 with Control Source=DateDiff("d",[PurchaseOrderApprovalDate],[ActualDeliveryDate])
I want to calculate the average of these values on the form (will be all values ActualDeliveryDate-PurchaseOrderApprovalDate for the tblDocInfo).
In summary: I have a field showing the number of days between the ActualDeliveryDate and PurchaseOrderApprovalDate. I would like the user to be able to compare this value for each docID to the average of all of the days between the ActualDeliveryDate and PurchaseOrderApprovalDate.
For some reason I am having a hard time with this....any suggestions?
-
May 19th, 2010, 10:23 AM
#2
Re: Calculate Fields in Domain Aggregate Functions using DateDiff
I am not sure if there is a shorter way of doing this but this logic is what I could think of at the moment...
1) Declare an Array. The size of the array will be the tables record count.
2) Loop through each record and find ActualDeliveryDate-PurchaseOrderApprovalDate and store it in the above array.
3) Find Average using the values stored in the array.
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 19th, 2010, 10:59 PM
#3
Re: Calculate Fields in Domain Aggregate Functions using DateDiff
On Form Header or Footer, create a control TextBox with ControlSource as:
=Avg([ActualDeliveryDate]-[PurchaseOrderApprovalDate])
or
=Avg(DateDiff("d",[PurchaseOrderApprovalDate],[ActualDeliveryDate]))
-
May 20th, 2010, 08:45 AM
#4
Thread Starter
Member
Re: Calculate Fields in Domain Aggregate Functions using DateDiff
Thank you! I was using DAvg and it was giving me an error #Name?. ugh.... Thanks again.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|