Time Math -- Easy in SQL what about in Aware?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Time Math -- Easy in SQL what about in Aware?

Post by BLOMASKY »

I have 2 attributes, Pickup and Arrival. Both are timestamp fields. They have BOTH been computed previously. For example, pickup 9:00 AM, arrival 9:45AM. Now the user wants to enter a new pickup time and I need to change the arrival time by the DELTA of the original pickup time and the new one. So if they enter, 9:20 pickup time, I need to add 20 minutes to the arrival.

Not sure how to code that in aware

Bruce
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Time Math -- Easy in SQL what about in Aware?

Post by BobK »

Out of curiosity, how would you do that in SQL?
Bob
joben
Posts: 225
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: Time Math -- Easy in SQL what about in Aware?

Post by joben »

Here is one idea that I tested, and it works:

First create a duration attribute called duration.

Activate this update rule:

Code: Select all

If BO.Pickup WAS CHANGED AND NOT(BO IS NEW) Then
BO.duration=BO.Pickup-OLD_VALUE(BO.Pickup)
BO.Arrival=BO.Arrival+BO.duration
Set it to:
Dynamic
Do not run on server
Form initialization: No

Came up with this in a few minutes so it might need some improvements.
Regards, Joakim

Image
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Time Math -- Easy in SQL what about in Aware?

Post by BLOMASKY »

BobK wrote: Fri Jan 27, 2023 8:16 pm Out of curiosity, how would you do that in SQL?

Update BO set Arrival = DateADD(mi, dateDiff(mi, oldPickup, pickup), Arrival)

Bruce
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Time Math -- Easy in SQL what about in Aware?

Post by aware_support »

Adding to a timestamp gives you another timestamp. Adding 1 means adding 1 hour. Adding 0.5 means adding 30 min.
Aware IM Support Team
BobK
Posts: 545
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: Time Math -- Easy in SQL what about in Aware?

Post by BobK »

BLOMASKY wrote: Sun Jan 29, 2023 6:19 pm
BobK wrote: Fri Jan 27, 2023 8:16 pm Out of curiosity, how would you do that in SQL?

Update BO set Arrival = DateADD(mi, dateDiff(mi, oldPickup, pickup), Arrival)

Bruce
Thanks
Bob
Post Reply