If you have questions or if you want to share your opinion about Aware IM post your message on this forum
#29351 by Rennur
Thu Jul 31, 2014 3:48 am
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

#29352 by Rennur
Thu Jul 31, 2014 4:31 am
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)

#29354 by hpl123
Thu Jul 31, 2014 1:47 pm
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.

#29360 by aware_support
Fri Aug 01, 2014 12:40 am
This works for us

#29362 by Rennur
Fri Aug 01, 2014 1:42 am
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 allIf Object IS NEW AND Object.Timestamp IS UNDEFINED
Then
Object.Timestamp=TIME_ADD(CURRENT_TIMESTAMP, -0.33)


Cheers

#29364 by Rennur
Fri Aug 01, 2014 1:52 am
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
#50572 by BobK
Fri Mar 15, 2019 12:47 pm
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.
#50580 by swiftinitpvtltd
Mon Mar 18, 2019 5:30 am
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.
#50581 by BobK
Mon Mar 18, 2019 2:22 pm
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

Who is online

Users browsing this forum: Google [Bot] and 10 guests