TIME_ADD function subtracting

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

TIME_ADD function subtracting

Post by Rennur »

Can anyone suggest a solution please?

I wan't to pre-define a timestamp attribute on entry.
When the object is being created, it is not subtracting the hours from the CURRENT_TIMESTAMP:
  • myBO.myTimestamp=TIME_ADD(CURRENT_TIMESTAMP, -myBO.Number)
Adding to the timestamp (without the - sign) works.

User Guide on TIME_ADD
Description:
Returns the timestamp resulting from adding/subtracting the specified number of hours to the specified timestamp
Parameters:
An expression producing timestamp and an expression producing a number to be added or subtracted (if the number is negative) to the timestamp
Example:
If  TIME_ADD (Account.OpeningTime), 4) = 07/04/2004 12:00 Then …

Tried:
myBO.myTimestamp=TIME_ADD(CURRENT_TIMESTAMP, -myBO.Number)
myBO.myTimestamp=TIME_ADD(CURRENT_TIMESTAMP, -(myBO.Number))

Cheers
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

Also tried:
Not Subtracting 20mins form CURRENT DATE
myBO.myTimestamp=TIME_ADD(CURRENT_TIMESTAMP, -0.33)

Addition is fine, adds 20mins
myBO.myTimestamp=TIME_ADD(CURRENT_TIMESTAMP, 0.33)
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Post by hpl123 »

Rennur wrote:Also tried:
Not Subtracting 20mins form CURRENT DATE
myBO.myTimestamp=TIME_ADD(CURRENT_TIMESTAMP, -0.33)

Addition is fine, adds 20mins
myBO.myTimestamp=TIME_ADD(CURRENT_TIMESTAMP, 0.33)
I also intend to use this function to add/subtract minutes so developers or support who knows if this is a bug please comment. Thanks.
Henrik (V8 Developer Ed. - Windows)
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

This works for us
Aware IM Support Team
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

This works for us - Support

No matter what I try I can't get it to subtract hours.
Any chance of sharing the working rule used to test this?

More tries:
myBO.myTimestamp=TIME_ADD(CURRENT_TIMESTAMP, -(0.33))
myBO.myTimestamp=TIME_ADD(CURRENT_TIMESTAMP, (0.33))

I have a workaround in place so I won't be purchasing a support ticket for this right now.

I would very much appreciate it if someone can please test out the subtracting.
RULE:

Code: Select all

If Object IS NEW AND Object.Timestamp IS UNDEFINED 
Then 
Object.Timestamp=TIME_ADD(CURRENT_TIMESTAMP, -0.33)
Cheers
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

Conclusion:
1) Cannot subtract time if the number contains decimal places. (bug)
2) Subtracting only works with whole numbers.
3) Adding time works with both decimals and whole numbers

Cheers
swiftinitpvtltd
Posts: 370
Joined: Sat Apr 28, 2018 3:33 am
Location: India
Contact:

Re: TIME_ADD function subtracting

Post by swiftinitpvtltd »

How do I add minutes to this time?
For example
TimeTest.TimeTestDisplay=TIME_ADD(TimeTest.TimeTestInput,4.30)

meaning 4 hours 30 minutes to current datetime.
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: TIME_ADD function subtracting

Post by BobK »

swiftinitpvtltd wrote:How do I add minutes to this time?
For example
TimeTest.TimeTestDisplay=TIME_ADD(TimeTest.TimeTestInput,4.30)

meaning 4 hours 30 minutes to current datetime.
Use fractions of a hour.
So 4.5 would be 4 hours and 30 minutes.
Bob
swiftinitpvtltd
Posts: 370
Joined: Sat Apr 28, 2018 3:33 am
Location: India
Contact:

Re: TIME_ADD function subtracting

Post by swiftinitpvtltd »

Thanks Bob. This may work. One issue is how do we compare this 4.5 numeric time with current time if its greater or less than now time. Current_Time. I need to compare it for some validation.
BobK
Posts: 544
Joined: Thu Jan 31, 2008 2:14 pm
Location: Cincinnati, Ohio, USA

Re: TIME_ADD function subtracting

Post by BobK »

We have a reservation system which does not allow a reservation to be made less then 1 hour and 30 minutes from the current time. So we have a rule similar to the following:

Reservation is a BO for the reservation.
Reservation.ReservationTime is a Time Stamp and is the time the user wants the reservation for

Our validation rule is like:

IF Reservation.ReservationTime < TIME_ADD(CURRENT_TIME, 1.5) Then
REPORT ERROR 'Invalid reservation time'


Just to clarify
In your example
TimeTest.TimeTestDisplay=TIME_ADD(TimeTest.TimeTestInput,4.30) 
the 4.30 does not mean 4 hours and 30 minutes, it really means 4 and 30 hundredths hours or 4 hours and 18 minutes.
To get 4 hours and 30 minutes (4 and a half hours), use 4.5
Bob
Post Reply